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.

 

How to control module on position and other module

How to control module on position and other module

Hi,
I would like to display a module in left position if there is no other module displayed. Is it possible with metamod ?

Kind regards,
Marcin

malin
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: How to control module on position and other module

Hi Marcin,

you could do this using a variation of the recipe on http://www.metamodpro.com/metamod/recip … not-appear

Code:

$position = "left"; /* the module position we are checking for. Customise this! */

$sql = 'SELECT count(*) as c from #__modules m, #__modules_menu mm ' .
  'WHERE mm.moduleid = m.id ' .
  'and m.published = 1 ' .
  'and (mm.menuid = ' .
  (int)$Itemid . ' or mm.menuid = 0) and mm.position = \'' . $moduleid . "'";

$db->setQuery( $sql, 0, 1 );
$row = $db->loadObject();

$only_me = ($row == null or $row->c <= 1); // there should be only one there - this MetaMod!

/* replace 101 with module id to display when there's nothing else in the specified position */
if ($only_me) return 101;

I haven't tested this but I think it should work well.
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
3319 Posts
User info in posts
Administrator has disabled public posting

Re: How to control module on position and other module

Hi.
Thank you for this code.

Unfortunately I get an error:

No valid database connection Unknown column 'mm.position' in 'where clause' SQL=SELECT count(*) as c from #__modules m, #__modules_menu mm WHERE mm.moduleid = m.id and m.published = 1 and (mm.menuid = 1 or mm.menuid = 0) and mm.position = '' LIMIT 0, 1
Including modules: 50

I don't have an access to the database to check the columns.
Please help.

Regards,
malin

malin
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: How to control module on position and other module

Hi Malin,

unfortunately on this forum (Agora) every time I type in "# __" (without the space in between) as a prefix for database tables, it replaces it with "jos_".

It's possible that your database prefix is not "jos_", and that could be the problem.

I also found some bugs in the recipe... Try this instead:

Code:

$position = "left"; /* the module position we are checking for. Customise this! */ 

$sql = 'SELECT count(*) as c from #__modules m, #__modules_menu mm ' .
  'WHERE mm.moduleid = m.id ' .
  'and m.published = 1 ' .
  'and (mm.menuid = ' .
  ((int)$Itemid) . ' or mm.menuid = 0) and m.position = \'' . $position . "'";

$db->setQuery( $sql, 0, 1 );
$row = $db->loadObject();

$only_me = ($row == null or $row->c <= 1); // there should be only one there - this MetaMod!

/* replace 101 with module id to display when there's nothing else in the specified position */
if ($only_me) return 101;

I should really test all the recipes before sending them out sad

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

Re: How to control module on position and other module

metamodguy,

I am a new user of you very impressive product Metamod Pro.  I used this article to get me started towards putting a slideshow in my header.  Actually there is no Joomla header element in this template, so I am using user4.  As you can see at http://www.joomla.seaworthy.com/ I am getting close.  So I wrote the following to position the metamod

#div-1a {
position:absolute;
top:100;
left:650;
width:295px;
}

I also tried it using the change and return commands outlined in your quick start.

And yes, I am new to php as well, so if this is wrong I won't be surprised.
I don't really care if the position is absolutely correct at this point I just want to get it to move at all, then I can fine tune it.  But no matter what I try, the metamod stays at user4.  Can you point me in the right direction?

JJonJoomla

sea25mx
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: How to control module on position and other module

Hi JJonJoomla,

are you trying to drop the slideshow module into the empty space below the search box?

If so, wouldn't it be better to just add a new module position into that space, rather than trying to put it into a different module position then using CSS to push it into place?

In any case, I can't see any mention of <div id="div-1a"> in your page output. If you want the CSS above to act on a div, then the div needs to have an id like that.

MetaMod will be useful for determining exactly which pages the module will appear on, but it's not designed to help you to position the module on the page - that's what CSS, module positions, and CSS Class Suffixes are for. If you want help editing your template to add a new module position in that space, try asking on the Joomla Template forum: http://forum.joomla.org/viewforum.php?f=466

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

Re: How to control module on position and other module

hi metamodguy,

Okay, thanks.  Perhaps due to my inexperience I misunderstood the product capabilities.

Best regards,

JJonJoomla

sea25mx
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: How to control module on position and other module

To be more specific, I was looking to use Metamod to get around doing a template modification which will be a lot of work for me.  There are, I suspect tens of thousands of Joomla sitebuilders that know very little about programming, like me. The basic problem seems to be no wysiwyg method of altering an existing template.  Short term solution for me will be I suspect, hire a programmer to edit the template.  Once past that particular hurdle, I can do most of the rest myself.  I still think you have an excellent product.  Build a wysiwyg template editor and you will rule the world.

Cordially,

JJonJoomla

sea25mx
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: How to control module on position and other module

Well, there are tools like Artisteer that can create templates from scratch. I believe it's pretty easy. Also google for Joomla template maker, and you might find some interesting stuff.

Sorry I can't help more.

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

Re: How to control module on position and other module

Yes,  I am familiar with the Artisteer product and will look further as you suggest.  BTW, Metamod Pro is really a brilliant product.  After better understanding it, I used one of your recipes to solve a space problem by displaying a random tower ad that changes upon page refresh.  Works like a charm.  Thanks!

JJonJoomla

sea25mx
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1675
Total Polls:
6
Total Posts:
5917
Posts this week:
6
User Info:
 
Total Users:
11584
Newest User:
allen6221
Members Online:
0
Guests Online:
169

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