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.

 

Make Module show on certain user IDs

Make Module show on certain user IDs

I need to make modules show on certain user IDs but they must be visible to all users

theseedsower
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Make Module show on certain user IDs

Can you please explain further what you mean by "on certain user ids"? I guess you don't mean "for certain logged in users" since you also want it to be visible to all users. But you'll need to clarify on exactly what types of pages, and possibly what type of component, you want the modules to appear on.

Thanks,
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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Make Module show on certain user IDs

This is an entry from my user id: http://thenag.us/topics/entry/uncategor … d-easyblog

This is my profile for EasyBlog: http://thenag.us/theseedsower/blog

I want all entries from my user id to show all modules and CSS presented on my profile

theseedsower
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Make Module show on certain user IDs

I had an old version of EasyBlog from Joomla 1.7 which I tested on. I hope it's the same on your version. Try this:

if ($option == 'com_easyblog'
    and $view == 'entry') {
  $query = 'sel' . 'ect created_by from #_' . '_easyblog_post where id = ' . (int)$id;
  $db->setQuery($query);
  $author_id = (int)$db->loadResult();
} else if ($option == 'com_easyblog'
    and $view == 'blogger') {
  $author_id = (int)$id;
} else return; // we're not on a page we can deal with

if ($author_id == 123) return AAA;
if ($author_id == 124) return BBB;
if ($author_id == 125) return CCC;
// replace 123, 124, 125 etc with the user ids you want to detect
// replace AAA, BBB, CCC with the module numbers to use
//   for each user.
// Add as many "if" lines as you need.

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Make Module show on certain user IDs

What if I need this to query a specific database? I have multiple databases on one install through MightySites and I need this work work for individual databases.

And can I use this for specific categories in EasyBlog?

Is this what it's supposed to look like? Because it's showing up on all EasyBlog pages...

if ($option == 'com_easyblog'
    and $view == 'entry') {
  $query = 'sel' . 'ect created_by from #_' . '_easyblog_post where id = ' . (int)$id;
  $db->setQuery($query);
  $author_id = (int)$db->loadResult();
} else if ($option == 'com_easyblog'
    and $view == 'blogger') {
  $author_id = (int)$id;
} else return;

if ($author_id == 365) return 847;

theseedsower
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Make Module show on certain user IDs

This code will talk to the database that Joomla is connected to. If you want to query a different database you can use Joomla's database classes or plain old PHP/mysql to do so.

With regard to the fact that your module is showing up on all pages, please read the FAQ http://www.metamodpro.com/metamod/faq and in particular:

1 - make sure the target module is set to "menu items: none" or set to a non-existent module position
2 - leave the "quick module id or position include" box in MetaMod EMPTY since you're using a PHP rule

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Make Module show on certain user IDs

About the separate databases with MightySites: I'm afraid I don't know how MightySites structures its databases. Can you point me to any documentation on this?

About separate categories in EasyBlog, you can do a very similar database call to get the category of a post.

e.g.

if ($option == 'com_easyblog'
    and $view == 'entry') {
  $query = 'sel' . 'ect category_id from #_' . '_easyblog_post where id = ' . (int)$id;
  $db->setQuery($query);
  $category_id = (int)$db->loadResult();
  if ($category_id == AAA) return XXX;
  if ($category_id == BBB) return YYY;
  if ($category_id == CCC) return ZZZ;
  // etc
  // replace AAA-CCC with the category ids you want
  // to test for, and XXX-ZZZ with the module ids to
  // display in each case.
}

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Make Module show on certain user IDs

About the separate databases with MightySites: I'm afraid I don't know how MightySites structures its databases. Can you point me to any documentation on this?

MightySites has terrible documentation so I'll try to explain. All databases use the same Joomla core files. When you change a file, it works on all databases. So I would need to specify the database prefix for each query.

theseedsower
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Make Module show on certain user IDs

So are you saying that MightySites uses the same MySQL database, but that the tables sinply have a different prefix per site?

If that's the case then it's easy to alter the PHP above:

if ($option == 'com_easyblog'
    and $view == 'entry') {
  $query = 'sel' . 'ect category_id from SITEPREFIX_easyblog_post where id = ' . (int)$id;
  $db->setQuery($query);
  $category_id = (int)$db->loadResult();
  if ($category_id == AAA) return XXX;
  if ($category_id == BBB) return YYY;
  if ($category_id == CCC) return ZZZ;
  // etc
  // replace AAA-CCC with the category ids you want
  // to test for, and XXX-ZZZ with the module ids to
  // display in each case.
}


So just replace SITEPREFIX with the prefix of the site you want to query. I hope that should solve it.

Best regards,
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
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1689
Total Polls:
6
Total Posts:
5941
Posts this week:
1
User Info:
 
Total Users:
5361
Newest User:
scotti64d
Members Online:
0
Guests Online:
189

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