Getting Articles With Category ID number

1,375 views
Skip to first unread message

Bar Saar

unread,
May 29, 2012, 6:29:15 AM5/29/12
to Joomla! General Development
Hey all.
I am kinda new into Joomla, and after taking some courses and making
some extensions i stumbled into a problem i cant seem to understand.

I am trying to get all the articles realted to the same category by
the id.
Lets say i got category id 1 and i want to get all the articles in
this category.

I have searched relationships in the DB and examples in extensions,
but couldn't find anything.

I can really use an idea, if you have any.

Thanks in advance.

Matt Thomas

unread,
May 29, 2012, 7:43:31 AM5/29/12
to joomla-de...@googlegroups.com
Have you looked at the way the core com_content extension does it yet? I'd guess that what you need can be found at https://github.com/joomla/joomla-cms/blob/master/components/com_content/models/category.php

Best,

Matt Thomas
Founder betweenbrain
Phone: 203.632.9322
Twitter: @betweenbrain





--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.


Sam Coult

unread,
May 29, 2012, 12:25:04 PM5/29/12
to joomla-de...@googlegroups.com
I guess the simplest (but not necessarily best) way would be:

$db = JFactory::getDbo();
$catid = "1";
$query = "SELECT * FROM $db->quoteName('#__content') WHERE catid = $db->quote($catid)";
$db->setQuery($query);
$articles = $db->loadAssocList();

Bar Saar

unread,
Jun 5, 2012, 7:57:24 AM6/5/12
to Joomla! General Development
I will look into your both solutions after i finish some projects.
I will post here the results.

Thanks :)

Bar Saar

unread,
Aug 28, 2012, 5:54:43 PM8/28/12
to joomla-de...@googlegroups.com
Ok so i have turned it into a component on account i needed to create a table in the database.
So i used my records instead of the articles, you can view in joomla extensions named Tip of the day FTW.

Thank you anyway :)
Reply all
Reply to author
Forward
0 new messages