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.

 

Metamod Pro & Flexicontent

Metamod Pro & Flexicontent

Hi,
i'm using Flexicontent.
I have 3 main categories (sectors.services.projects) that contains some sub categories.
When i show content from one category (i.e. a project), i have to show two modules that shows the "related sectors" and the "related services" for the shown project.
In main menu, i have just a menu "project" ancd not a submenu linking to each project, so, by now, in order to show the two modules i'm using an hidden menu linking to each project.
I would like to change this terrible method with metamod, but i don'nt know how to show a module according to a Flexicontent category (not single article).

I'll appreciate any help.

Thank you
Maurizio

maurizio.gabriele
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Metamod Pro & Flexicontent

Hi Maurizio,

I may need a little more info from you about what you want to do, but I have a couple of suggestions already.

(1) detect if you are on a particular category page

if ( $option == "com_flexicontent" and $view == "category" ) {
  $cat_id = JRequest::getInt( "cid" );
  if ($cat_id == 2) return XXX; // module XXX for category id 2
  if ($cat_id == 3) return YYY; // module YYY for category id 3
  // add more as appropriate
}


(2) detect the category id of an item you are viewing, and use this to change modules:

$item = (int)$id;
if ( $option == "com_flexicontent" and $view == "items" and $item > 0) {

  $query = "select catid from #__flexicontent_cats_item_relations where itemid = ";
  $query .= " $item";
  $db->setQuery( $query );
  $results = $db->loadResultArray();
  if ( !is_array( $results ) ) return; // short-circuit if there are no categories
  if ( in_array( 2, $results ) ) return XXX; // module XXX for category id 2
  if ( in_array( 3, $results ) ) return YYY; // module YYY for category id 3
  // add more as appropriate
}

This works even when the item is in more than one category.


I hope these 2 examples cover your situation. If your situation is different to those described please write back with more info about your particular setup and these recipes can be modified further.

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

Re: Metamod Pro & Flexicontent

Hi Stephen,
i have a doubt.

I have category "services" with ID 4
and a subcategory "design" with ID 5
and a subcategory "certificatioN" with ID 5

Services
|_ design
|_ certification

i need to display a different module when i'm showing any article assigned to "design" or "certification" or to any future subcategories assigned to "services" (without modification of metamod).
Is it possible ?

Thank You
Maurizio

maurizio.gabriele
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Metamod Pro & Flexicontent

Ok, I'm still a little confused...

- Do you mean that the module in "design" should be different from the module in "certification"? Should these be different from the module on the "Services" page?

- For future subcategories in Services, should each subcategory have a different module, different from the ones in "Services", "Design" and "Certification"?

- Can you confirm whether the modules are to be displayed on the Category page, or on the item pages, for items within that category?


I often end up making a chart like this to help me plan which modules are going to go onto which pages:

PAGE..................MODULE
Services cat..........101
Design cat............102
Certification cat.....105
Articles in Services..106
Articles in Design....222
Articles in Cert......44
Arts in future subcats of Services...55

Could you make something like that please?

If you want code to detect "all child categories and grandchild categories of a certain category" then that's possibly but a little more challenging. I've done similar things for VirtueMart and the standard Joomla category system.


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: Metamod Pro & Flexicontent

I'm sorry, i'll try to be more clear.

This is the structure, but with more subcategories:

Services
  |_ design
  |_ certification
  |_ ...
  |_ (next one)
Sectors
  |_airports
  |_bridges
  |_ ...
  |_(next one)
Projects
  |_ Project A
  |_ Project B
  |_ ...
  |_ (next Project)

- Each subcategory contains articles

- If i have a service shown (any article belonging to "service" or his subcategory like "design")i have to show, on the right position of the template, a custom module showing "related sectors" and another custom module showing "related projects"

- If i have a sector shown (any article belonging to "sector" or his subcategory like "airport")i have to show, on the right position of the template, a custom module showing "related services" and another custom module showing "related projects"

- If i have a project shown (any article belonging to "project" or his subcategory like "project A")i have to show, on the right position of the template, a custom module showing "related services" and another custom module showing "related sectors"

So, the needs are the following:

- find a way to display a module (just one) according to articles belonging to a specific category (category and all his subcategories)

- find a way to get the same behaviour, without any change or support, when a new article will be added in a subcategory

if you send me an email address, i can send you a link.

Thank You for your time.
Maurizio

maurizio.gabriele
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Metamod Pro & Flexicontent

I just had a look at the way that Flexicontent does its categories. It was simpler than I thought - each category simply has a "parent_id" that contains the category id that it belongs to. In your case, as long as you are not going any deeper than 2 levels deep, this makes it nice and easy and efficient to retrieve the data.

From what you wrote above I don't see any mention of putting modules onto the "category" pages themselves - only on the article pages.

It also appears that the "related services" and "related projects" modules are related to the particular top-level category that you are in, and NOT to the sub-category. So I think you are saying that every article in Sectors, Sectors/airports, Sectors/bridges etc will use EXACTLY the same module. Correct? You didn't mention anything about different subcategories within the same category requiring different modules.

So in the end this is reasonably simple:

if ($option == "com_flexicontent" and $view == "items") {
  $item = (int)$id;
  $query = "select c.id, c.parent_id from #__categories c, #__flexicontent_cats_item_relations ir where ir.catid = c.id and ir.itemid = $item";
  $db->setQuery($query);
  $result = $db->loadObjectList();
  $all_cats = array();
  foreach ($result as $o) {
    if ( $o->id && !in_array( $o->id, $all_cats ) ) $all_cats[] = $o->id;
    if ( $o->parent_id && !in_array( $o->parent_id, $all_cats ) ) $all_cats[] = $o->parent_id;
  }
  // customise from here on, to detect the category ids that you are looking for:
  if ( in_array( 4, $all_cats ) ) return XXX; // module XXX for category 4 descendents
  if ( in_array( 5, $all_cats ) ) return YYY; // module YYY for category 5 descendents
  if ( in_array( 6, $all_cats ) ) return ZZZ; // module ZZZ for category 6 descendents
}


This will display module XXX for every article in category 4 or one of category 4's subcategories; module YYY for category 5 and its subcategories; and module ZZZ for category 6 and its subcategories.

If an article is in more than one of the top level categories then only 1 module will be shown; the 1st one that matches.

Please let me know how you get on.

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

Re: Metamod Pro & Flexicontent

Hi Stephen,

i've used that code, customizing the following last line:

  if ( in_array( 50, $all_cats) ) return 237;

Where 50 is the projects ID main category and 237 is the module "related services". Nothing happen...

If i put 237 in the quick module position the module appear, so, there must be something wrong in the code (i'm sorry i'm not a programmer).

Ciao
Maurizio

maurizio.gabriele
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Metamod Pro & Flexicontent

Were you viewing an article that was in the Projects category (or a subcategory of it)? You have to be on an article view page, not a category view page.

Perhaps you could turn on MetaMod Advanced Debug mode and paste the output from that just so I can double check?

Also, do you know what your database class prefix is? the code above says "jos_categories" etc, but perhaps yours is different.

Officially you should use "#_ _categories" and "#_ _flexicontent..." (but without the space between the 2 underscores) but this forum software I am using actually converts that to "jos_" when the post is done... very annoying.

So try changing the table names to "#_ _categories" and "#_ _flexicontent_cats_item_relations" (without the spaces and quotes) in the recipe above and see if that makes a difference.

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: Metamod Pro & Flexicontent

Hi Stephen,
first of all i really appreciate your support and the time dedicated to this issue.
I've prepared some images to attach, but now i discover that i can'nt attach images..

Nothing changes.
I think the problem is in category, sub category and sub-sub category.

Take a look:

Servizi ID=59 (main category)
  Architettura e Contesto Urbano  ID=63 (sub category)
     Urbanistica e pianificazione urbana   ID=61  (sub-sub category)

The Article Shown belong to the sub cat with ID=63 and the sub-sub cat with ID=61(as primay and secondary categories)
I need to show the module for all articles that are under cat ID=59

This is the debug
Metamod ALL
Page Identification
The PHP code below may be used to help MetaMod to identify the exact page that you are viewing. For help using this feature, please click here.
if (
$option == 'com_flexicontent'
and $view == 'items'
and $id == '294'
and $Itemid == '224'
and JRequest::getVar('version') == '4' /*!*/
and JRequest::getVar('loadcurrent') == true /*!*/
and JRequest::getVar('cid') == '63'
) return XXX; /* replace XXX with the module ID or position to display */
Note: lines starting with "and" and ending with /*!*/ contain rules that may be optional. You may wish to leave them out.
MetaMod debug info:
Module ID: 307
$option: com_flexicontent
$view: items
$id: 294
$Itemid: 224
$timezone: default
$language: it-it
$language_code: it
$language_region: it
Including modules:

maurizio.gabriele
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Metamod Pro & Flexicontent

I think we can do it with a workaround, in an easier way.

Each article is assigned to a specific CONTENT TYPE

All project articles belongs to Content Type "PROGETTI" with ID=2
All services articles belongs to Content Type "SERVIZI" with ID=3
All sectors articles belongs to Content Type "SETTORI" with ID=4

I think the better idea is to show the module when the article shown belongs to a specific content type id.

Dear "chef", do you heve another recipe for me ?

Thank You.
Maurizio

maurizio.gabriele
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10772
Newest User:
alton29318
Members Online:
0
Guests Online:
203

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