Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » (com_easyblog) display module in a...
(com_easyblog) display module in a category and Blog category
(com_easyblog) display module in a category and Blog category
Hi
how to display module in a category and Blog category (easyblog)
similar topics on the example of k2
http://www.metamodpro.com/forums/topic?id=380
http://www.metamodpro.com/forums/topic?id=466
I left the code that appears only in the category, and is not displayed in the blog category//
if ($ option == "com_easyblog" and $ view == "categories") {
$ catId = JRequest:: getCmd ('id', '0 ');
if ($ catId == 0 or JRequest:: getVar ("view") == "entry") {
$ blogId = JRequest:: getVar ('id');
$ query = "select catid from felhf_easyblog_post where id =". $ blogid;
$ db-> setQuery ($ query);
$ catId = $ db-> loadResult ();
}
}
if ($ catId == 5) return 83;
in theory should work but I do not understand the syntax))
Re: (com_easyblog) display module in a category and Blog category
Hi,
Your PHP assumes the following things. Can you please check that they are correct?
- there's a table called felhf_easyblog_post
- this has a column called "catid" for the category id and a column called "id" for the post id
- when you are viewing a blog post, the internal URL has option=com_easyblog&view=categories&id=XXX (that looks like it could be wrong... if you're doing a database query in the easyblog_post table, wouldn't the view be "article" or "post" or "item" or something like that, and not "categories"?)
Lastly, the variable names should not have a space between the "$" and the name. There are a number of extra spaces in your code that may be stopping it from working. Here's a copy of what you wrote without the spaces (it still may not work, but at least the spaces won't be the problem):
if ($option == "com_easyblog" and $view == "categories") {
$catId = JRequest::getCmd('id', '0');
if ($catId == 0 or JRequest::getVar("view") == "entry") {
$blogId = JRequest::getVar('id');
$query = "select catid from felhf_easyblog_post where id =". $blogid;
$db->setQuery($ query);
$catId = $db->loadResult ();
}
}
if ($catId == 5) return 83;
hope that helps,
Stephen
Re: (com_easyblog) display module in a category and Blog category
I copied the code from the rules for k2, and it may not be working, but is rather an example). rummaged through the component code easyblog rearranged differently values but I can not do.) hmmm)
Thanks Stephen, still try other options. if you will have time to help I will be grateful)
Re: (com_easyblog) display module in a category and Blog category
Ok, try this:
if ($option == "com_easyblog" ) {
$catid = 0;
if ($view == "categories") $catid = (int)$id;
else if ($view == "entry") {
$query = "select category_id from #_ _easyblog_post where id =". (int)$id;
$db->setQuery($query);
$catid = $db->loadResult();
}
echo "It's in category: " . $catid . "<br />";
// now you can use $catid to check if user is viewing
// anything in particular caategories. Replace XXX and
// YYY with module ids to return for their respective
// category ids.
if ($catid == 1) return XXX;
if ($catid == 2) return YYY;
}
NOTE: remove the space from this part of the PHP before using:
#_ _easyblog_post
Cheers,
Stephen
Re: (com_easyblog) display module in a category and Blog category
Just a note about the "#_ _" thing: just use the code above but remove the space between the underscores. Joomla is smart enough to convert that to the proper database prefix for your site.
Cheers,
Stephen
Re: (com_easyblog) display module in a category and Blog category
Would there be a fast way to adapt the code above to test for EasyBlog individual article ID as opposed to category ID? I want to be able to add modules to specific articles (though not within article body itself, otherwise I would use loadposition). So if the link is "...index.php?option=com_easyblog&view=entry&id=68&Itemid=190" — Itemid=190 is the category, and id=68 is the article.
Re: (com_easyblog) display module in a category and Blog category
ok, that's really easy to do without even doing a database lookup:
if ($option == "com_easyblog" and $view == "entry") {
if ((int)$id == 68) return XXX;
if ((int)$id == 69) return YYY;
if ((int)$id == 70) return ZZZ;
// add more as appropriate...
// and swap XXX, YYY and ZZZ for the module id(s) you want to use for each blog entry.
}
Cheers,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » (com_easyblog) display module in a...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5944
- Posts this week:
- 2
- User Info:
- Total Users:
- 7658
- Newest User:
- carre82601
- Members Online:
- 0
- Guests Online:
- 193
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked