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.

 

can metamod do the job?

Re: can metamod do the job?

Ok, I see what's going on now.

The MultiCategories category ids are different to standard Joomla category ids. So really we need different checks for each type of ID.

- first we check to see if we're on a standard com_content page, then check for the standard category ids
- then we check for com_multicategories and extract the category id from the URL - if found, we check that against a different list.

The next problem however is that each article may be in more than one multicategory. When we retrieve the catid from the URL, that's obviously only 1 of the possible categories that the article is actually in. So we need to make a way to extract ALL the possible (multi)categories that an article is in, given only its article id. This is actually quite difficult due to the way multicategories works... each multicategory is based on a Joomla category, but also contains a list of arbitrary article ids inside its parameters. So to find out which multicategories an article is in, we have to retrieve ALL the multicategories from the database and loop through them to get the list of articles from each one. For large databases this is going to be slow. I'm going to give you a recipe that does it the long way. Caching would help.

Ok, so here's some code that can get a list of all multicategories that an article is in:

if (! function_exists("all_multicategories_for_article")) {
  function all_multicategories_for_article( $id ) {
    $id = (int)$id;
    $db =& JFactory::getDBO();
    $query = 'select mc.id, mc.params, mc.articles, c.catid from #_' . '_multicategories mc ';
    $query .= " left join #_" . "_content c on c.id = $id ";
    $query .= " where mc.params like concat('%catid=', c.catid, '%') ";
    $query .= " or mc.articles like '%$id%' ";
    $db->setQuery($query);
    $results = $db->loadAssocList();
    $ret = array();
    foreach ($results as $multicat) {
      $jcat = @$multicat['catid'];
      $params = new JParameter($multicat['params']);
      if ($params->get('catid') == $jcat) {
        $ret[] = $multicat['id'];
      } else {
        if (in_array($id, explode(",", $multicat['articles']))) {
          $ret[] = $multicat['id'];
        }
      }
    }
    return $ret;
  }
}

// detect article pages on com_multicategories:
if ($option == "com_multicategories" and $view == "article") {
  $categories = all_multicategories_for_article( (int)$id);
  // detect your multicategory ids here, and return the appropriate
  // modules (replace XXX, YYY, ZZZ with module ids)
  if (in_array(5, $categories)) return XXX;
  if (in_array(6, $categories)) return YYY;
  if (in_array(7, $categories)) return ZZZ;
}

// now detect normal com_content pages:
$catid = 0;
if ($option == "com_content") $catid = $content_genius->info("category_id");
if ($catid == 68) return "27, 93, 83, 116";
if ($catid == 51) return "27, 93, 83, 118";
if ($catid == 57) return "27, 93, 83, 125";
if ($catid == 55) return "27, 93, 83, 125";
if ($catid == 54) return "27, 93, 83, 127";
if ($catid == 45) return "27, 93, 83, 118";



I set this up on your site. You'll need to customise the bits with XXX, YYY, ZZZ above because I don't know what multicategories you want to detect, and which modules you want to return for those.

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: can metamod do the job?

hi stephen,

i am very appreciative of your thoughtful help, but i think we may have  a bit of a misunderstanding. my objective was to get jomcomment to appear on article pages when clicked from multicategory blog pages. i have no idea if this is a possible function or application of metamod pro. i simply asked and was under the impression that we were discussing possible solutions for getting jomcomment to appear on those pages where it does not. 

titles clicked on from the front page have jomcomment component appearing normally, but when you click the same title from multicategory blog pages, it does not. example: http://www.zhongwenmovies.com/index.php … Itemid=111
click the image and jomcomment does not load.

i'm very sorry if this has wasted your time in any way. 

the multicategories guy says he may be able to hack the jomcomment code, that it's a jom comment problem, but it will cost.

thanks mate.

baituo01
Intermediate Modder
ranks
useravatar
Offline
46 Posts
Administrator has disabled public posting

Re: can metamod do the job?

Hi baituo01,

As I said in my post, you need to customise it still! This is because the multicategories id numbers are DIFFERENT from the normal Joomla category numbers.

The checks that you do above (e.g. for 68, 51, 57 etc) are checking for normal Joomla category numbers.

Where I put the 5, 6, 7 and XXX, YYY, ZZZ things above are where you need to work out which multicategory id numbers you want to use.

I didn't fill in all these for you, because multicategories are different from normal categories. You might have an article that's in Joomla category 68, but in both multicategories 5 and 6, for example. So you're going to need to decide what goes where.

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: can metamod do the job?

ok, i will give this some thought / time. glad we are on the same page.

thanks much.

baituo01
Intermediate Modder
ranks
useravatar
Offline
46 Posts
Administrator has disabled public posting

Re: can metamod do the job?

somehow the site seems faster. is that perhaps just coincidence?

baituo01
Intermediate Modder
ranks
useravatar
Offline
46 Posts
Administrator has disabled public posting

Re: can metamod do the job?

Coincidence. It was nothing I did smile

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: can metamod do the job?

hi stephen,

when i use the code you provided as a test, i can return modules like 116 (ie.  if (in_array(5, $categories)) return 116;) in multi(category) #5, which is the movies category. but no matter what i do i do not see jomcomment appearing below videos as it does when titles are clicked from the front page. jomcomment should (hopefully) appear under the videos like it does via front page - though it's a comment extension not a module per se.

am i missing (or misunderstanding) something? 

if i use the code you gave me above without changing anything, why does this force jomcomment to appear on multicategory blog pages? 

if i add more modules to additional multicategories, like:

if (in_array(5, $categories)) return 116, etc, etc, etc;
if (in_array(6, $categories)) return 116, etc, etc, etc;
if (in_array(7, $categories)) return 116, etc, etc, etc;

it adds the modules in right position only. it puts modules onto multicategory pages, but not the jomcommment extension itself.

thanks.

baituo01
Intermediate Modder
ranks
useravatar
Offline
46 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1696
Total Polls:
6
Total Posts:
5941
Posts this week:
7
User Info:
 
Total Users:
5412
Newest User:
crooms27548
Members Online:
0
Guests Online:
102

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