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.

 

Control modules based on page content/keywords/description for J.2.5

Re: Control modules based on page content/keywords/description for J.2.5

Hello Stephen,
I tried metamod with the beez5 template(in current joomla installation) and worked perfectly.

Also i make some tests condition with my current template(ja teline iv)
tried to disable all modules from the website, and the metamod could not delivery the module again. I also tried metamod with other recipes in my current template and worked normally.

As i can understand its a "conflict" with my current template and the recipe. Please help me understand the where this conflict should appear.

Thank you!

gdi
Beginner Modder
ranks
useravatar
Offline
12 Posts
Administrator has disabled public posting

Re: Control modules based on page content/keywords/description for J.2.5

Hello,

I have tried alot to make metamod described recipe work with my template, with NO success.

In my previous website I had excactly the same template (for J1.5) and worked like a charm.

From my part. I have remove some PHP codes of the template, Plugins, Modules but the recipe could not work.

I have install a new Joomla2.5 with this templates, but from a fresh download, the recipe could not work.

I contacted the joomlart team for this problem, then they said to me that this is propably a Module problem, as they are native Joomla2.5 template.

I have ask them the same question that i make to you, What, Where or How can I solve this problem, the response was the same as here "No Response".

From your experience, where I should check to make the described recipe to work with metamod and my template ?

Thank you again!

gdi
Beginner Modder
ranks
useravatar
Offline
12 Posts
Administrator has disabled public posting

Re: Control modules based on page content/keywords/description for J.2.5

Hi gdi,

I'm happy to log into your site to be able to see the problem directly. Hopefully the answer will also be obvious. I'll e-mail you my e-mail address and further instructions.

Sorry for the delay in getting back to you. I've been away for a week and wasn't able to do much support work during that time.

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

Re: Control modules based on page content/keywords/description for J.2.5

Hi,
I am having the same problem with Joomla 2.5 not showing the module based on meta keywords.
If I replace the PHP code with return 378; it works fine; just to show that the basics are set up right!

I really would appreciate some help as this will be very useful to me. I have set up an online shopping category in my forum.

Here is a clip from the page source:
<meta name="keywords" content="10&amp;quot; Android tablet bought online, Shopping Online, MAIN FORUM, Over 50 Seniors Forum" />

The debug output:
Advertising by keywords in meta

MetaMod debug info:
Module ID: 379
$option: com_kunena
$view: topic
$id: 1483573
$Itemid: 110
$timezone: Europe/London
$language: en-us
$language_code: en
$language_region: us
Including modules: None

and the module PHP:
// To set it up, just edit the "$source", "$case_sensitive",
// "$allow_as_substrings", "$names" and "$max_num_modules"
// variables below. The "$names" array contains the
// words/phrases that you want to search for, and the module
// ID or module position to use when any one of them is found.

$source = "keywords"; /* either "keywords", "description" or "content" */

$case_sensitive = false; /* set to true or false */

/* if you set $allow_as_substrings to true, then the search
* will pick up "billybob thornton" even if you are trying
* to search for "bob thornton". Set it to false to make
* sure that there's an least 1 non-alphabet character on
* each end of the string you are searching for.
*/
$allow_as_substrings = false; /* set to true or false */

$max_num_modules = 3; /* it will just give you the first 3 it finds */

/* In this array, the first part is the text to search for, and
* the last part is the module id to include if that text is
* found. Add as many as you like.
* Remember every line has to end in a comma EXCEPT the last one!
*/
$names = array(
    "Shopping" => 378
);

/*****************************************/
/* you shouldn't need to edit below here */
/*****************************************/
$document = JFactory::getDocument();

switch ($source) {
  case "keywords":
  $content = $document->getMetaData('keywords');
  break;

  case "description":
  $content = $document->getMetaData('description');
  break;

  default:
  $buffer = $document->getBuffer();
  $content = $buffer['component'][''];
}

$names_escaped = array();
$names_case = array();
foreach ($names as $key=>$module) {
  if (!$case_sensitive) {
    $key = strtolower($key);
  }
  $names_escaped[preg_quote($key)] = $module;
  $names_case[$key] = $module;
}
$names = $names_escaped;
$names_only = str_replace('/','\/',implode("|", array_keys($names)));

$word_boundary = $allow_as_substrings ? '' : '\b';

$result = preg_match_all("/" . $word_boundary
  . "(" . $names_only . ")"
  . $word_boundary . "/"
  . ($case_sensitive ? '' : 'i'), $content, $all);

if ($result > 0) {
  $modules = array();

  foreach ($all[0] as $matched_name) {
    $module = $names_case[$case_sensitive ?
      $matched_name : strtolower($matched_name)];
    if ( !in_array( $module, $modules) ) {
      $modules[] = $module;
    }
  }
  if ( count($modules) > $max_num_modules ) {
    return array_slice( $modules, 0, $max_num_modules );
  }
  return $modules;
}

Head Buzzer
Buzz50 Seniors

Buzz50
Mr
Beginner Modder
ranks
useravatar
Offline
16 Posts
User info in posts
Administrator has disabled public posting

Re: Control modules based on page content/keywords/description for J.2.5

Hi,

I have narrowed the problem down to the JA T3 template framework. Use of this framework stops the standard method of getting the page content from working. i.e. from inside a module you are normally able to use the following to get the component content:

  $document = JFactory::getDocument();
  $buffer = $document->getBuffer();
  $content = $buffer['component'][''];

With the JA T3 framework in place, this does not work, sadly. I'm currently exploring other ways to get hold of the component content in this case... stand by.

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

Re: Control modules based on page content/keywords/description for J.2.5

A followup on that: there are some major differences in the way that the modules are rendered in JAT3. When MetaMod Pro is in use, the MetaMod modules get rendered BEFORE the main page component is rendered, so it can't get access to that information.

I wrote a post on the JAT3 forum about it:

http://www.joomlart.com/forums/showthre … etaMod-Pro

So at the moment, unfortunately there is no solution to this problem. With the Pro version of MetaMod, you can't use the technique above for getting hold of the main content of the page, to parse it for particular strings. The main component has not been generated by the time the MetaMod is executed.

If you only wish to check standard articles for their content, and parse that content, then there are ways you can do that, however. You can say:

$content = $content_genius->info("introtext");

or combine introtext and fulltext:

$content = $content_genius->info("introtext") . $content_genius->info("fulltext");

However, as stated above this only works for articles. The original method worked no matter what type of component you were using on the page.


Sorry that's all I can come up with unless the JAT3 people get back to me with some brilliant solution!

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

Re: Control modules based on page content/keywords/description for J.2.5

Thanks for this reply.

There is another possibility here for me.

Am I able to reference the URL of the page?

I want to show specific modules depending on what Kunena category is being viewed.

A typical URL would be www.buzz50.com/forum/shopping

The Kunena category ID, as it happens, is 400 if that can be used?

I know that I can do it by menu item but that may not have been clicked.

Head Buzzer
Buzz50 Seniors

Buzz50
Mr
Beginner Modder
ranks
useravatar
Offline
16 Posts
User info in posts
Administrator has disabled public posting

Re: Control modules based on page content/keywords/description for J.2.5

ok, good ideas.

1 - yes, you can do it on URL. e.g.

// modules 11, 12, and 13
if ($core_genius->check('url startswith http://www.buzz50.com/forum/shopping')) return "11, 12, 13";

2 - you may also be able to do it on forum id. Try activating Advanced Debug mode in MetaMod, and view some of the pages in the forum. Post the results back to here – it's possible the forum id may be exposed, even if it's not in the URL.

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

Board Info

Board Stats:
 
Total Topics:
1674
Total Polls:
6
Total Posts:
5919
Dormant:
User Info:
 
Total Users:
11798
Newest User:
thomas4936
Members Online:
0
Guests Online:
161

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