Joomla! Discussion Forums



It is currently Fri Nov 27, 2009 9:52 pm (All times are UTC )

 


Forum rules

Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.



Post new topic Reply to topic  [ 9 posts ] 
Author Message
Posted: Mon Nov 02, 2009 12:47 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Oct 28, 2009 10:57 am
Posts: 7
Hi,
I do not want to show the number of hits and author in list view of my category. Instead I want to show a custom attribute "URL" I have added to the articles.

Can someone tell me how I can change the category list view to show my new field?
Thanks.


Top
  E-mail  
 
Posted: Mon Nov 02, 2009 1:56 pm 
Joomla! Ace
Joomla! Ace
Offline

Joined: Thu Jul 10, 2008 2:51 am
Posts: 1175
You'll want to do that in /templates/yourtemplate/html/com_content/category/blog_links.php.

_________________
http://www.nodwell.net
http://templates.nodwell.net
Custom Web Development & Joomla! Templates


Top
  E-mail  
 
Posted: Mon Nov 02, 2009 2:16 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Oct 28, 2009 10:57 am
Posts: 7
jnodwell,

I have done that but the problem I am facing is my custom attribute is not present in the params collection.

Let me elaborate a little bit of my problem. I have added a custom field in the articles. It is working fine there. Now I want to display my custom field instead of hits when category is clicked. I know, I have to edit default_item.php present in (components\com_content\views\category\tmpl) as I am using list mode. For blog you have to edit blog_links.php.

I am not able to get my custom field from the params collection and I am not able to find a way how to add this in params.Thanks


Top
  E-mail  
 
Posted: Mon Nov 02, 2009 2:39 pm 
Joomla! Ace
Joomla! Ace
Offline

Joined: Thu Jul 10, 2008 2:51 am
Posts: 1175
How did you add your custom attribute URL field to the articles?

You put the new attribute in /components/com_content/views/category/tmpl/default.xml?

Then you should be able to access its value with $this->params->get('your_variable_name') inside the default_items.php file?

_________________
http://www.nodwell.net
http://templates.nodwell.net
Custom Web Development & Joomla! Templates


Top
  E-mail  
 
Posted: Mon Nov 02, 2009 2:54 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Oct 28, 2009 10:57 am
Posts: 7
I followed the following process to do that.

1-changed joomla database in "jos_content".
Code:
ALTER TABLE `jos_content` ADD `url` MEDIUMTEXT NOT NULL


2- In /administrator/components/com_content/admin.content.html.php
Code:
<td><label for="url"><?php echo JText::_( 'url' ); ?></label></td><td><input class="inputbox" type="text" name="url" id="url" size="40" maxlength="255" value="<?php echo $row->url; ?>" /></td>"

3-In /libraries/joomla/database/table/content.php
Code:
var $url            = null;


4-In /administrator/components/com_content/controller.php
Code:
$row->url= $item->url;


5-In components/com_content/views/article/tmpl/default.php
Code:
<?php echo $this->escape($this->article->url); ?>


Top
  E-mail  
 
Posted: Mon Nov 02, 2009 4:48 pm 
Joomla! Ace
Joomla! Ace
Offline

Joined: Thu Jul 10, 2008 2:51 am
Posts: 1175
Well, I'm testing this out on a dev box here, and so far what I've been able to do is use the extra jos_content column in the editor but not in the category list.

1. jos_content .. add column url
2. libraries\joomla\database\table\content.php ... add var $url=null; to class def.
3. administrator\components\com_content\models\article.xml .. add parameter to input custom url var called 'url' of textarea type near author alias param
4. administrator\components\com_content\controller.php .. add $form->set('url', $row->url; (around line 559)

at this point the custom field is saving in the db and showing up in the article editor but $item->url is not available in default_items.php in template yet though

I'll keep fiddling with it.

I'm sure there is a better way to do this without hacking all these core files, though.

_________________
http://www.nodwell.net
http://templates.nodwell.net
Custom Web Development & Joomla! Templates


Top
  E-mail  
 
Posted: Tue Nov 03, 2009 5:27 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Oct 28, 2009 10:57 am
Posts: 7
That will be great. Thanks.


Top
  E-mail  
 
Posted: Wed Nov 04, 2009 5:38 pm 
Joomla! Ace
Joomla! Ace
Offline

Joined: Thu Jul 10, 2008 2:51 am
Posts: 1175
jnodwell wrote:
Well, I'm testing this out on a dev box here, and so far what I've been able to do is use the extra jos_content column in the editor but not in the category list.

1. jos_content .. add column url
2. libraries\joomla\database\table\content.php ... add var $url=null; to class def.
3. administrator\components\com_content\models\article.xml .. add parameter to input custom url var called 'url' of textarea type near author alias param
4. administrator\components\com_content\controller.php .. add $form->set('url', $row->url; (around line 559)

at this point the custom field is saving in the db and showing up in the article editor but $item->url is not available in default_items.php in template yet though

I'll keep fiddling with it.

I'm sure there is a better way to do this without hacking all these core files, though.


Keeping steps 1-4, what you can do at this point is use $item->slug to get the article id and then do a db lookup on jos_content for your url column on that article id. Not pretty, but would do what you want.

_________________
http://www.nodwell.net
http://templates.nodwell.net
Custom Web Development & Joomla! Templates


Top
  E-mail  
 
Posted: Tue Nov 10, 2009 6:18 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Oct 28, 2009 10:57 am
Posts: 7
Surely it will do the job.... Thanks for helping.


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

Quick reply

 



Who is online

Users browsing this forum: bickyz and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group