Author Topic: Insert module in Sobi2 Component  (Read 18809 times)

0 Members and 1 Guest are viewing this topic.

Offline burnsai

Re: Insert module in Sobi2 Component
« Reply #40 on: 15. September 2011, 18:34:05 »
I'm not sure what I'm doing wrong - but I get this error message whenever I insert the code into my details view:

Fatal error: Call to undefined function Sobi2InsertMod() in /home/internat/public_html/components/com_sobi2/sobi2.entry.php(1264) : eval()'d code on line 818


Here is the code I insert into the details view:
<?php  echo  Sobi2InsertMod("sobi" , "xhtml");  ?>

Any Idea what I'm doing wrong?
Country: Unknown  Unknown  |  OS: Windows 7/Server 2008 R2 Windows 7/Server 2008 R2 |  Browser: Chrome 13.0.782.220 Chrome 13.0.782.220 | View Profile International Love Scout


Offline Poffen

  • SOBI Team
  • Moderator
  • Sobi Hero
  • *
  • Posts: 2296
  • Reviews:

    What is it?

Re: Insert module in Sobi2 Component
« Reply #41 on: 15. September 2011, 20:31:58 »
Hi burnsai,

I'm not sure what I'm doing wrong - but I get this error message whenever I insert the code into my details view:

Fatal error: Call to undefined function Sobi2InsertMod() in /home/internat/public_html/components/com_sobi2/sobi2.entry.php(1264) : eval()'d code on line 818

Any Idea what I'm doing wrong?

Did you forget to put the following code into the custom.functions.php file (your_installation/components/com_sobi2/includes/inc/custom.functions.php):

Code: [Select]
function sobi2InsertMod( $position, $style = -2 )
{
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer( 'module' );
$params = array('style'=> $style );
$contents = '';
foreach ( JModuleHelper::getModules( $position ) as $mod)  {
$contents .= $renderer->render( $mod, $params );
}

return $contents; // do something with the module output
}

Regards Poffen
Joomla - 1.5.7, Sobi2 - 2.9.0.1
PHP - 5.2.4, MySQL - 5.0.51a, Apache - 2.2.8, Firefox - 3.0.3
Country: Norway Norway |  OS: Linux (Ubuntu) Linux (Ubuntu) |  Browser: Chrome 12.0.742.112 Chrome 12.0.742.112 | View Profile

Do you want continued ongoing development, new features and active support?
Please write a review or just vote for SOBI on JED.

Offline Country-Reiten

  • Sobi Newbie
  • *
  • Posts: 16
Re: Insert module in Sobi2 Component
« Reply #42 on: 24. November 2011, 16:03:24 »
Hm, seem to be interesting, but the download does not work. I only get xxxx.par files.

Country: Germany Germany |  OS: Windows 7/Server 2008 R2 Windows 7/Server 2008 R2 |  Browser: Firefox 8.0 Firefox 8.0 | View Profile

Offline mahdoo

Re: Insert module in Sobi2 Component
« Reply #43 on: 21. December 2011, 16:59:06 »
Great bit of code, works perfectly in my details template.

But.........

Don't know how to get it to show a module on the v-card template. The v-card template is just a <td> so inserting <?php echo Sobi2InsertMod('rightsobi2','sobi'); ?> gives you a module position inside the table with as many instances as you have listings on that page.

The <table class="sobi2Listing"> on the v-card template is made in the "sobi2.listing.php file and has two instances I think the second instance is the one (shown here):

Code: [Select]
/*
* show items in this category
*/
if( !$config->cacheL2Enabled
|| !( $output = $config->sobiCache->getContent( $requestParams, "entrieslist") )
|| !( $cPageNav = $config->sobiCache->getContent( $requestParams, "pagenav") )
) {
$output = "\n\t\t<table class=\"sobi2Listing\">";
$output .= $sobi2Frontend->getListing( $sobi2Cat );
$output .= "\n\t\t\t</tr>\n\t\t</table>\n";
    if( $config->cacheL2Enabled ) {
$config->sobiCache->addContent( $output, $requestParams, "entrieslist" );
    }
}
echo $output;
    }

Would it be possible to add the <?php echo Sobi2InsertMod('rightsobi2','sobi'); ?> code to this file so that it is before the table and in a div like this:
<div class="sobi2mods">
<?php echo Sobi2InsertMod('rightsobi2','sobi'); ?>
</div>

So I can make it float right as I did on the details view template.

I have been guessing at the code but everything I do just breaks the whole site.
I hope someone can help.    :blink:
Country: Thailand Thailand |  OS: Windows 7/Server 2008 R2 Windows 7/Server 2008 R2 |  Browser: Firefox 8.0 Firefox 8.0 | View Profile

Offline Poffen

  • SOBI Team
  • Moderator
  • Sobi Hero
  • *
  • Posts: 2296
  • Reviews:

    What is it?

Re: Insert module in Sobi2 Component
« Reply #44 on: 25. December 2011, 16:10:54 »
Hi mahdoo,

Quote
Would it be possible to add the <?php echo Sobi2InsertMod('rightsobi2','sobi'); ?> code to this file so that it is before the table and in a div like this:
<div class="sobi2mods">
<?php echo Sobi2InsertMod('rightsobi2','sobi'); ?>
</div>

Are you are looking for a way to output a module on the top of the entries list in category view? If so, the frontend.class.php file is the appropriate file to check out. However, I think this can easily be achieved with a very simple Sobi2 plugin (using method "onEntriesList"), in which case you don't have to hack the sobi2 core.

Regards Poffen
Joomla - 1.5.7, Sobi2 - 2.9.0.1
PHP - 5.2.4, MySQL - 5.0.51a, Apache - 2.2.8, Firefox - 3.0.3
Country: Norway Norway |  OS: Linux (Ubuntu) Linux (Ubuntu) |  Browser: Chrome 15.0.874.106 Chrome 15.0.874.106 | View Profile

Offline mahdoo

Re: Insert module in Sobi2 Component
« Reply #45 on: 28. December 2011, 06:10:43 »
Thanks for the reply Poffen,

I was actually trying to get some modules to show up on the right side of the entries list.

After much trial and error I found that this code below put after line 154 on the sobi2.listing.php file works but not perfectly. Unfortunately the modules also show up after (not to the right of) the category list pages aswell (Iwould rather they not show up at all on those pages).

Code: [Select]
    $output = "<div class=\"sobi2mods\">";
$output .= $catList . Sobi2InsertMod("risobi2lis" , "sobi2mods");
$output .= "</div>";
    echo $output;

A simpler method using metamod would have worked to show modules on specific sobi2 pages but I am using a hacked ja purity template which has a collapsing right side column. When you assign a module to right side the column is expanded even on those sobi2 pages that the module is not assigned to. So did not work for me.

I would like to know if a plugin would still be a viable option in my case? I am not keen on hacking core files especially as I know nothing at all about PHP.

Thanks, Mahdoo
« Last Edit: 28. December 2011, 06:13:20 by mahdoo »
Country: Thailand Thailand |  OS: Windows 7/Server 2008 R2 Windows 7/Server 2008 R2 |  Browser: Firefox 8.0 Firefox 8.0 | View Profile

Offline Poffen

  • SOBI Team
  • Moderator
  • Sobi Hero
  • *
  • Posts: 2296
  • Reviews:

    What is it?

Re: Insert module in Sobi2 Component
« Reply #46 on: 01. January 2012, 23:15:39 »
Hi Mahdoo,

I'm not sure if your requirements can be easily achieved, without major hacks to the Sobi2 core. 

Quote
but I am using a hacked ja purity template which has a collapsing right side column. When you assign a module to right side the column is expanded even on those sobi2 pages that the module is not assigned to.

Why not put the modules in the right column instead of the center column next to the V-Cards? You should be able to configure the display of the modules so that only your selected module(s) are displayed on the Sobi2 pages.

Quote
I would like to know if a plugin would still be a viable option in my case? I am not keen on hacking core files especially as I know nothing at all about PHP.

A plugin option will only let you display modules on top of the V-Card list, and not next to the list.

Regards Poffen
Joomla - 1.5.7, Sobi2 - 2.9.0.1
PHP - 5.2.4, MySQL - 5.0.51a, Apache - 2.2.8, Firefox - 3.0.3
Country: Norway Norway |  OS: Linux (Ubuntu) Linux (Ubuntu) |  Browser: Chrome 15.0.874.106 Chrome 15.0.874.106 | View Profile

Tags: