SQL statement category list
-
- Joomla! Apprentice
- Posts: 12
- Joined: Fri Jul 10, 2009 8:41 pm
SQL statement category list
Hi,
I'm looking for the place where I can alter the SQL select statement that is used for the list of articles within a category.
Thank you very much!
Kind regards,
Martijn Schram
I'm looking for the place where I can alter the SQL select statement that is used for the list of articles within a category.
Thank you very much!
Kind regards,
Martijn Schram
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: SQL statement category list
You cannot do that without changing the core files. What are you trying to do? Maybe the change can be done with a plugin as well.
Olaf
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 12
- Joined: Fri Jul 10, 2009 8:41 pm
Re: SQL statement category list
I know I have to change the core files (done it before )
I have made a custom plugin that inserts 5 articles when you add a new article.
In this way each article has 5 subarticles (see http://www.watkoopik.nl for an example, pages are in Dutch though....). In the jos_content table is a custom field that I use to identify the type of subarticle (1 is the main article).
The problem is that if you click on a category you will see all articles times 5.
So I want to include a WHERE statement like WHERE cust_type=1
Regards,
Martijn
I have made a custom plugin that inserts 5 articles when you add a new article.
In this way each article has 5 subarticles (see http://www.watkoopik.nl for an example, pages are in Dutch though....). In the jos_content table is a custom field that I use to identify the type of subarticle (1 is the main article).
The problem is that if you click on a category you will see all articles times 5.
So I want to include a WHERE statement like WHERE cust_type=1
Regards,
Martijn
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: SQL statement category list
You could try to hide it by using a template overwrite of the category list view.
- create a folder in your template folder called "html" (if it doesn't exists)
- create a folder in that html folder called "com_content" (if it doesn't exists)
- create a folder in that com_content folder called "category" (if it doesn't exists)
- copy the file .../components/com_content/views/category/tmpl/default_item.php in this .../templates/[your-template]/html/com_content/category/ folder
- open that file
- find the following lines:
Code: Select all
<?php foreach ($this->items as $item) : ?>
- and replace it with the following:
(you will need to set your_parameter to your sql_coloumn or to a parameter params->get('your-parameter') to get your parameter)
Code: Select all
<?php foreach ($this->items as $item) : if($item->your_parameter) continue; ?>
- save the file
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 12
- Joined: Fri Jul 10, 2009 8:41 pm
Re: SQL statement category list
Olaf,
Thank you for your solution.
I've added this code to the default_items.php file:
But it does not seem to work. I think the $item->cust_type statement does not retrieve the correct value. I have checked it with other code (if(1==1) continue) and that hided all the articles. How can I link the $item->cust_type statement to the correct value?
BTW: Why do I have to put the file in the template directory? Doesn't that get me in trouble with new releases of Joomla?
Thanks
Martijn
Thank you for your solution.
I've added this code to the default_items.php file:
Code: Select all
<?php foreach ($this->items as $item) :
if($item->cust_type==1) continue;
?>
BTW: Why do I have to put the file in the template directory? Doesn't that get me in trouble with new releases of Joomla?
Thanks
Martijn
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: SQL statement category list
well, if you put it into the template you can still upgrade to a new version, if you make a change in any of the core files you will need to make the changes again, after you upgraded to the new version.mschram wrote:BTW: Why do I have to put the file in the template directory? Doesn't that get me in trouble with new releases of Joomla?
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 12
- Joined: Fri Jul 10, 2009 8:41 pm
Re: SQL statement category list
I have done the following:
1) Added field cust_type to jos_content (type = tinyint)
2) Added to libraries\joomla\database\table\content.php
3) Addedto administrator/components/com_content/controller.php
4) Added
to administrator/components/com_content/models/article.xml
This all seems to work: I get an extra combobox in the administrator part of the articles.
But once I try to use the field in the front-end (through item->cust_type) I get no data.
For example:
in components\com_content\views\category\tmpl\default_items.php
I replaced $item->cust_type with $item->title, and then I did see the title.
The statement $item->cust_type does not seem to work.
What am I missing here????
Thanks Martijn
1) Added field cust_type to jos_content (type = tinyint)
2) Added
Code: Select all
var $cust_type = null;
3) Added
Code: Select all
$form->set('cust_type', $row->cust_type);
4) Added
Code: Select all
<param name="cust_type" type="list" default="" label="Article type" description="Article type">
<option value="1">Beschrijving</option>
<option value="2">Specificaties</option>
<option value="3">Afbeeldingen</option>
<option value="4">Handleidingen</option>
<option value="5">Recencies</option>
</param>
This all seems to work: I get an extra combobox in the administrator part of the articles.
But once I try to use the field in the front-end (through item->cust_type) I get no data.
For example:
Code: Select all
<td><?php echo $item->cust_type; ?>
<a href="<?php echo $item->link; ?>">
<?php echo $this->escape($item->title); ?></a>
<?php $this->item = $item; echo JHTML::_('icon.edit', $item, $this->params, $this->access) ?>
</td>
I replaced $item->cust_type with $item->title, and then I did see the title.
The statement $item->cust_type does not seem to work.
What am I missing here????
Thanks Martijn
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: SQL statement category list
Mod Note: Moved to Core Hacks and Patches
Olaf
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 12
- Joined: Fri Jul 10, 2009 8:41 pm
Re: SQL statement category list
I found a workaround for the category list, but I still want to use the $item->cust_type statement.
Can someone help me?
Big Thanks!
Martijn
Can someone help me?
Big Thanks!
Martijn