Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

(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))

Aslan
Beginner Modder
ranks
useravatar
Offline
14 Posts
User info in posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

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)

Aslan
Beginner Modder
ranks
useravatar
Offline
14 Posts
User info in posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: (com_easyblog) display module in a category and Blog category

Thank you very much Stephen). Your code is working, instead of (#_ _) you need to put a prefix table joomla. My project is to test mode. necessarily at startup acquiring pro version

Aslan
Beginner Modder
ranks
useravatar
Offline
14 Posts
User info in posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

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.

mirphi
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: (com_easyblog) display module in a category and Blog category

Worked beautifully. Thank you!

mirphi
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5910
Total Posts Today:
1
User Info:
 
Total Users:
10152
Newest User:
kasautiizindagiikay
Members Online:
0
Guests Online:
370

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