GK Module Position in a K2 template

Feel free to talk about everything related to our Joomla Products
Rate this topic: Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.
GK User
Wed Dec 14, 2011 11:49 pm
I have a project where I need to load a module position in a k2 template but I dont know how I would get that module to load TWN 2 styling. I can never get the heading to show correctly.. I know this is outside the scope of support but a closed mouth don't get fed.
User avatar
Platinum Boarder

teitbite
Thu Dec 15, 2011 3:35 am
Hi

K2 is displayed in mainbody position only, so rest of the module positions are available. Your problem is that You probably have no menu item for this K2 element to be able to attached the modules to it.

Here You will find a solution for the exact same problem but for NSP module. Believe me K2 works the same way: http://wiki.gavick.com/questions/how-to ... s-working/
User avatar
Moderator

GK User
Thu Dec 15, 2011 6:36 am
Seems we have our signals crosssed.. I really mean loading a GK module inside of a K2 template as in the image. Now I'm able o do with with no problem with custom_module just fine and it includes the header and shown but when I use a NSP module there is no header so I have to fake it.

Meaning I havve to use a empty custom_module on top of a NSP just for a header. even in this image the header is active for the NSP.. but it won't display.

These two modules are loading on a module position that I coded into the actual K2 category template category.php
User avatar
Platinum Boarder

teitbite
Thu Dec 15, 2011 4:07 pm
Hi

Och. So it's about the modules style :). Most probably the header were not designed here. Can You please tell me which template is it ? Acctually an exact url to the page with a problem is the fastest way to figure out what to do.
User avatar
Moderator

GK User
Thu Dec 15, 2011 7:25 pm
sure this is my sandbox http://base.8balla.com/ Here let me give you a few clue. I had use the top module positions name and I got headers on mod_custom but they wouldnt show on any gavick modules. Then I changed the name of the module position to k2zone1 - k2zone4 I make 4 module positions in the k2 category template. But after changing the names of the new positions I get NO headers at all. Now then I give the module positions the xhtml attribute I get a header title but no way to really style the title.
User avatar
Platinum Boarder

teitbite
Fri Dec 16, 2011 12:48 am
Hi

Can You give me the exact ulr to the page with this example ? I cannot find it.

Please also tell me how did You added the position and where. Just tell me the code and file name.
User avatar
Moderator

GK User
Sat Dec 17, 2011 4:57 am
Well thats a good sign, it means the integration is working well.. So i put tags where the module loads and K2 starts.. I have 4 module positions in the template but as I said I can't make headers



teitbite wrote:Hi

Can You give me the exact ulr to the page with this example ? I cannot find it.

Please also tell me how did You added the position and where. Just tell me the code and file name.
User avatar
Platinum Boarder

GK User
Sat Dec 17, 2011 5:09 am
As far as code I've tried load module and this:

Code: Select all
<?php
$position = 'user1';
$params      = array('style'=>'xhtml');
$document   = &JFactory::getDocument();
$renderer   = $document->loadRenderer('k2mod1');
$contents = '';
foreach (JModuleHelper::getModules($position) as $mod)  {   
   $contents .= $renderer->render($mod, $params);
}
echo $contents;
?>


so I finally settled on using the Modules Anywhere plugin. it gave the same results as the rest but was easier to implement .
User avatar
Platinum Boarder

teitbite
Sat Dec 17, 2011 6:54 pm
Hi

Please take a look here http://base.8balla.com/?tp=1

Like You can see Your module positions uses style "xhtml", try replace it to "gk_style" like all modules with headers I can see here.
User avatar
Moderator

GK User
Sat Dec 17, 2011 9:07 pm
Man I swear I've used gk_style before and I didn't get the same results. But that was when I was hacking on a k2 item page. At any rate this time it did the trick and opens up millions of possibilities.

WORKING CODE:

Code: Select all
    <div class="pull_k2_mod">



<?php
$position = 'k2zone1';
$params      = array('style'=>'gk_style');
$document   = &JFactory::getDocument();
$renderer   = $document->loadRenderer('module');
$contents = '';
foreach (JModuleHelper::getModules($position) as $mod)  {   
   $contents .= $renderer->render($mod, $params);
}
echo $contents;
?>
</div>



$position = 'k2zone1';
has to be changed to the module position you want to load for those that may see this post and want to use the code.

you will also have to use the "clean" suffix in your module to get rid of extra padding.

Thanks to Teitbite we now have a new tool to customize the templates with..
User avatar
Platinum Boarder

teitbite
Sun Dec 18, 2011 3:43 pm
Hi

That's really clever :) I would use {loadposition k2zone1} in article code to display module there, but You're solution is much better for large amout of content.
User avatar
Moderator

GK User
Mon May 14, 2012 3:28 pm
Great trick!

Thanks a lot!
User avatar
Expert Boarder

teitbite
Mon May 14, 2012 6:48 pm
Hi

I'm looking at it right now and I'm wondering if all this is neccessary.

Looks like this part is the crucial one:

Code: Select all
foreach (JModuleHelper::getModules('k2zone1') as $mod)  {
echo $mod;
}
User avatar
Moderator

GK User
Sat May 26, 2012 10:00 am
Thats fine for just loading a module.. but you'll get no module styling, and I have to have styling on all of my custom module positions.
User avatar
Platinum Boarder

GK User
Sat May 26, 2012 10:12 am
As a matter of fact you can go here to see how I've been using it for my customers:

http://beta.2wyred.com/index.php?option ... Itemid=102

Just login with demo / demo

Notice the position of the user menu when logged in.. The K2 category is chopped up, and custom positions on the items pages.. it's also integrated with Jreviews to boot..

But this site is trash now because Jreviews is coming out with a new media version.. not going to do this much work twice on these templates
User avatar
Platinum Boarder

teitbite
Mon May 28, 2012 6:58 am
Hi

For module styling You can always use the one from template by adding a part of html to script loading module:

Code: Select all
foreach (JModuleHelper::getModules('k2zone1') as $mod)  {
echo '<div class="moduletable">' . $mod . '</div>';
}
User avatar
Moderator

GK User
Mon May 28, 2012 10:03 pm
Now that looks cool.. just added it to dreamweaver as a sniplet.. I see it's going to get a lot of use. Thanks bro
User avatar
Platinum Boarder

teitbite
Tue May 29, 2012 11:38 am
Hi

Yes I'm using this a lot. Try debug "$mod" You will see some usefull stuff like $mod->title for module title and so on.
User avatar
Moderator


cron