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.

 

Jomgenius commands for MetamodPro

Jomgenius commands for MetamodPro

Hi Stephen,

I have this complicated URL structure that comes from a sort and filter module for K2.

I use it to filter City and Guitar Style. That returns a list a teachers that aswers to these attributes.

I've designed banners for each style and each cities.

Task:
I want to return just one banner (some have cities, others have styles on them), using jom genius commands with metamod pro. I would call the right module (each banner as its own joomla module ID).

My Problem:
A search can return both city and style. I don't want 2 banners to load at the same time.
URL structure is complicated.
For now, each banner is associated with a menu item. This is a problem.
The best solution would be to rely only on URL expressions "contains" trigger.
Also, a search is returned over a preexisting menu Item URL

Example -  K2 Item URL (menu item):
This is a simple menu item for a teacher profile: http://www.quebecguitare.ca/professeurs … simon-gag/

(Search Result String)
This is a search result returned from that menu item: http://www.quebecguitare.ca/professeurs … temid=1204

Result: the Search result overrides the content of the page returned by the first URL. The second part of the URL starting from /itemlist/filter?searchword29=MTL&searchword31=Acoustique&moduleId=855&Itemid=1204 is the relevent part that would be exclusively used for jomgenius calling the banner module.

Otherwise, the first part would be triggering the module with jomgenius.

Illustration (Search Result String):
Here is a typical URL - http://www.quebecguitare.ca/professeurs … temid=1204

Scenario mixing K2 Item URL (menu item) strings and Search Results Strings:
IF URL Contains City and Style == Only Return "Style" Banner
             Examples (searchword31 = style K2 Extra Field ID):
             URL Contains >> ?searchword31=Acoustique
             URL Contains >> ?searchword31=Classique


IF URL Contains ONLY Teacher Name (no ?searchword29 and ?searchword31)  == Only Return "City" Banner associated with that teacher (list of ID)
          (Teacher ID a,b,c,d,e == Banner X for Montreal)
          (Teacher ID f,g,h,i,j == Banner Y for Québec)

IF URL Contains Teacher Name AND City or Style  == Only Return "Style" Banner (?searchword31)

Could you provide a Jom Genius list of command to get me started on these conditions to call the right Module ID with metamodpro?


Thank  you Stepen
Best Regards

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Jomgenius commands for MetamodPro

Hi again, long time no hear! As usual you're coming up with some great scenarios wink

I think I understand what you're saying, and I'll do my best to replicate that in code. Try this:

// teacher ids who will receive banner X
// the banner module id comes first followed by array of teacher names that may appear in the URL
$teachers = array(
  123 => array('/gabriel', '/clement', '/felix',  '/daniel', '/francis', '/jean-c', '/emilie'),
  456 => array('/simon-mart','/simon-gag','/simon-gue','/guylaine'),
  789 => array('/philippe') // (last item in list does not end in comma)
);
$styleModules = array(
  'Classique'=>55, // module to display for classique
  'Acoustique'=>66 // module to display for acoustique (last item in list does not end in comma)
);

$hasCity = $core_genius->check("url contains searchword29");
$hasStyle = $core_genius->check("url contains searchword31");

if ($hasCity and $hasStyle) {
  $style = JRequest::getVar("searchword31");
  return @$styleModules[$style];
}

// if we get to here, it's missing city or style or both.
// now check for teacher names in URL:
$teacherModule = null;
foreach ($teachers as $m_id => $teacher) {
  if ($core_genius->check("url contains any of ",$teacher)) {
    $teacherModule = $m_id;
  }
}

// no city, no style, but has a teacher: show module for the city that teacher is associated with
if (!$hasCity and !$hasStyle and $teacherModule) {
  return $teacherModule;
}

// has a style and a teacher: disregard city of teacher and display style banner
if ($hasStyle and $teacherModule) {
  $style = JRequest::getVar("searchword31");
  return @$styleModules[$style];
}
// if we reach here then it was none of the scenarios above! e.g. may have teacher and city but no style.
// so perhaps we can add this one:
if ($hasCity and $teacherModule) {
  return $teacherModule;
}
// end!

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: Jomgenius commands for MetamodPro

Hi Stephen, thank you very much for your time, you are truly a genius to me!

Almost there....
The only thing missing is to return the city banner when the style is not there but this expression is:
searchword29=GAT
searchword29=MTL
searchword29=QC

The problem I have is that this URL will follow the city of the teacher /emilie (which is montreal), but we are not at emilie's page anymore, the URL has been overriden by a search:

http://www.quebecguitare.ca/professeurs … Itemid=926

Therefore ?searchword29=QC should override "montreal" in this case and return the banner from Québec (QC)

Here is my new code, this is the only thing doesn't work I think so far in my debug process:
// teacher ids who will receive banner X
// the banner module id comes first followed by array of teacher names that may appear in the URL
$teachers = array(
  874 => array('/gabriel', '/clement', '/felix',  '/daniel', '/francis', '/jean-c', '/emilie'),  // Montréal
  875 => array('/simon-mart','/simon-gag','/simon-gue','/guylaine'),                      // Québec
  873 => array('/philippe') // (last item in list does not end in comma)                 // Gatineau
);

$styleModules = array(
  'Acoustique'=>858, // module to display for classique
  'Électrique'=>859, // module to display for classique
  'Blues'=>860, // module to display for classique
  'Classique'=>862, // module to display for classique
  'Country'=>863, // module to display for classique
  'Débutant'=>864, // module to display for classique
  'Enfants'=>865, // module to display for classique
  'Folk'=>867, // module to display for classique
  'Jazz'=>868, // module to display for classique
  'Metal'=>869, // module to display for classique
  'Rock'=>870, // module to display for classique
  'Ukulélé'=>872 // module to display for classique (last item in list does not end in comma)         
);

$hasCity = $core_genius->check("url contains searchword29");
$hasStyle = $core_genius->check("url contains searchword31");

if ($hasCity and $hasStyle) {
  $style = JRequest::getVar("searchword31");
  return @$styleModules[$style];
}

// if we get to here, it's missing city or style or both.
// now check for teacher names in URL:
$teacherModule = null;
foreach ($teachers as $m_id => $teacher) {
  if ($core_genius->check("url contains any of ",$teacher)) {
    $teacherModule = $m_id;
  }
}

// no city, no style, but has a teacher: show module for the city that teacher is associated with
if (!$hasCity and !$hasStyle and $teacherModule) {
  return $teacherModule;
}

// has a style and a teacher: disregard city of teacher and display style banner
if ($hasStyle and $teacherModule) {
  $style = JRequest::getVar("searchword31");
  return @$styleModules[$style];
}

// if we reach here then it was none of the scenarios above! e.g. may have teacher and city but no style.
// so perhaps we can add this one:
if ($hasCity and $teacherModule) {
  return $teacherModule;
}
// end!


Thank you, have a great weekend Stephen.
Regards

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Jomgenius commands for MetamodPro

In the meantime, I was wondering if you had any Logic suggestions on the possibilities of combining the Style and the City on the same banner to further the concept of my landing pages?

Thank you
Regards

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Jomgenius commands for MetamodPro

Ok, I think the only thing that has to change is the last set of checks. In the last section I guessed that if there's a teacher and a city, that we should use the city of the teacher. But you're saying that the teacher (alone) gets overridden by the new city search, that means we take the city instead of the teacher's city. So try this:

// teacher ids who will receive banner X
// the banner module id comes first followed by array of teacher names that may appear in the URL
$teachers = array(
  874 => array('/gabriel', '/clement', '/felix',  '/daniel', '/francis', '/jean-c', '/emilie'),  // Montréal
  875 => array('/simon-mart','/simon-gag','/simon-gue','/guylaine'),                      // Québec
  873 => array('/philippe') // (last item in list does not end in comma)                 // Gatineau
);

$styleModules = array(
  'Acoustique'=>858, // module to display for classique
  'Électrique'=>859, // module to display for classique
  'Blues'=>860, // module to display for classique
  'Classique'=>862, // module to display for classique
  'Country'=>863, // module to display for classique
  'Débutant'=>864, // module to display for classique
  'Enfants'=>865, // module to display for classique
  'Folk'=>867, // module to display for classique
  'Jazz'=>868, // module to display for classique
  'Metal'=>869, // module to display for classique
  'Rock'=>870, // module to display for classique
  'Ukulélé'=>872 // module to display for classique (last item in list does not end in comma)         
);

$hasCity = $core_genius->check("url contains searchword29");
$hasStyle = $core_genius->check("url contains searchword31");

if ($hasCity and $hasStyle) {
  $style = JRequest::getVar("searchword31");
  return @$styleModules[$style];
}

// if we get to here, it's missing city or style or both.
// now check for teacher names in URL:
$teacherModule = null;
foreach ($teachers as $m_id => $teacher) {
  if ($core_genius->check("url contains any of ",$teacher)) {
    $teacherModule = $m_id;
  }
}

// no city, no style, but has a teacher: show module for the city that teacher is associated with
if (!$hasCity and !$hasStyle and $teacherModule) {
  return $teacherModule;
}

// has a style and a teacher: disregard city of teacher and display style banner
if ($hasStyle and $teacherModule) {
  $style = JRequest::getVar("searchword31");
  return @$styleModules[$style];
}

// if we reach here then it was none of the scenarios above! e.g. may have teacher and city but no style.
// In this case we take the city, not the city of the teacher
if ($hasCity and $teacherModule) {
  $city = JRequest::getVar('searchword29');
  if ($city == 'GAT') return 873;
  if ($city == 'MTL') return 874;
  if ($city == 'QC') return 875;
}
// end!

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: Jomgenius commands for MetamodPro

...meanwhile, I'm not sure what you're asking about the logic of combining city and style on the same banner. Are you looking for PHP code, or just some graphical ideas? If graphical, you're probably talking to the wrong person!

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: Jomgenius commands for MetamodPro

...meanwhile....

LOL! Yes about logic.

So far the scenario has banners with one element on it: either the city or the style.
I was asking about the possibilities of combining both city and style on the same banner when the search result calls for that.

But maybe this is a completely different set of logic. Do you think it would be possible to insert this new scenario in the current logic.

I think the current logic was based on making choices when presented with 2 variables, so I am not too sure about this.

Thank you
Regards

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Jomgenius commands for MetamodPro

The last modification worked for the teacher (alone) gets overridden by the new city search.

Thank you Stephen.
Regards

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Jomgenius commands for MetamodPro

I did more troubleshooting.

This URL structure doesn't seem to work with the City or the Style search alone, but when combined the right banner is returned.

Ex.: with City only
http://www.quebecguitare.ca/professeurs … Itemid=850

Ex.: with Style only
http://www.quebecguitare.ca/professeurs … Itemid=850

Result:
No banner is returned

Expected Result;
Current logic would apply

Updated Code:

Code:

// teacher ids who will receive banner X 

// the banner module id comes first followed by array of teacher names that may appear in the URL
$teachers = array(
  874 => array('/thomas-d', '/thomas-b', '/gabriel', '/clement', '/felix',  '/daniel', '/francis', '/jean-c', '/emilie', '/montreal/liste'),          // Montréal
  875 => array('/simon-mart','/simon-gag','/simon-gue','/guylaine', '/quebec/liste'),                                                                   // Québec
  873 => array('/philippe', '/gatineau/liste') // (last item in list does not end in comma)                                                            // Gatineau
);

$styleModules = array(
  'Acoustique'=>858, // module to display for classique
  'Électrique'=>859, // module to display for classique
  'Blues'=>860, // module to display for classique
  'Classique'=>862, // module to display for classique
  'Country'=>863, // module to display for classique
  'Débutant'=>864, // module to display for classique
  'Enfants'=>865, // module to display for classique
  'Folk'=>867, // module to display for classique
  'Jazz'=>868, // module to display for classique
  'Metal'=>869, // module to display for classique
  'Rock'=>870, // module to display for classique
  'Ukulélé'=>872 // module to display for classique (last item in list does not end in comma)         
);

$hasCity = $core_genius->check("url contains searchword29");
$hasStyle = $core_genius->check("url contains searchword31");

if ($hasCity and $hasStyle) {
  $style = JRequest::getVar("searchword31");
  return @$styleModules[$style];
}

// if we get to here, it's missing city or style or both.
// now check for teacher names in URL:
$teacherModule = null;
foreach ($teachers as $m_id => $teacher) {
  if ($core_genius->check("url contains any of ",$teacher)) {
    $teacherModule = $m_id;
  }
}

// no city, no style, but has a teacher: show module for the city that teacher is associated with
if (!$hasCity and !$hasStyle and $teacherModule) {
  return $teacherModule;
}

// has a style and a teacher: disregard city of teacher and display style banner
if ($hasStyle and $teacherModule) {
  $style = JRequest::getVar("searchword31");
  return @$styleModules[$style];
}

// if we reach here then it was none of the scenarios above! e.g. may have teacher and city but no style.
// In this case we take the city, not the city of the teacher
if ($hasCity and $teacherModule) {
  $city = JRequest::getVar('searchword29');
  if ($city == 'GAT') return 873;
  if ($city == 'MTL') return 874;
  if ($city == 'QC') return 875;

// end!

Thank you
Regards

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Jomgenius commands for MetamodPro

Ok about combining banners with style and city: that's really not difficult to add to the logic. You're just going to have to create 3x12=36 banners to combine style and city...

The code could be restructured like this:

$banners = array(
'MTL-Acoustique'=>101,
'MTL-Électrique'=>102,
etc etc
);
$hasCity = $core_genius->check("url contains searchword29");
$hasStyle = $core_genius->check("url contains searchword31");
if ($hasCity and $hasStyle) {
  $key = JRequest::getVar('searchword29') . '-' . JRequest::getVar('searchword31');
  return @$banners[$key];
}

That could go above your other code. Simple.

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

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:
290

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