When a registered user adds a new entry in your SobiPro powered business directory in your Joomla site you might want to add a link pointing back to his Community Builder profile. Sounds simple... but the powerful templating system of SobiPro might be cryptic even for advanced users. And you might not have a membership in SobiPro club - BTW, worth every penny!

Here is one way you can do this!

I am assuming here, that you have both components (SobiPro and Community Builder) installed and configured correctly, and you published the mandatory link to the Community Builder user profile, and that has the Itemid of 123 (tou can check the actual ItemID in Menu manager).Also I assume, that you have some basic PHP and XSL knowledge.

Basically there are two template files you need to modify.

First, on active SobiPro template, you need to add in the template.php file the function we will call to do the magic. Remember, the code is a basic version, you can - and probably, you should - enhance it here and there, but basically works, is tested on SobiPro ver. 1.0.8 [ Sparrow ] Community Builder ver.1.9 and Joomla 2.5.9.

So, open your template.php in SobiPro interface, and insert this function:

  public static function ownerName( $id )
     $name = SPFactory::db()
                ->select( 'name', '#__users', array( 'id' => $id ) )
    if (!empty($name)) {
      return '<p>Added by:  <span class="name" itemprop="name"><a href="/index.php?option=com_comprofiler&task=userprofile&user='.$id.'&Itemid=123">' . $name . '</a></span></p>';

What the function does? Simply grabs the user's name from the Joomla users database table (you can change the code to retrieve for example the name set up in the Community Builder, which can be different), and based on that, and the user_id passed to the function by the attribute, builds the link to the Community Builder profile, then assembles the whole string wich will be returned to the details template to be shown in the listing. You can see, that there are at least two spots where you can improve the code: you can - in fact, you should - add to it the Joomla routing, and replace the plain English text with true, translatable language strings.

the second spot you should edit is the  entry>details.xsl template, or whatewer other spot you want to use the info.

Open the template, and locate the spot where you want to show the information. Paste there this code:

        <xsl:variable name="author">
          <xsl:value-of select="entry/author" />
        <xsl:value-of select="php:function( 'TplFunctions::ownerName' , $author )" disable-output-escaping="yes" />

What this part of the code is doing? Basically the first three lines of code are building up the variable needed to call our function above, and the fourth line calls the function and inserts the data returned by it.

Category: SobiPro hacks

Visit http://sprinklerrepairguy.com to find out more regarding Lawn Irrigation

Learn more about https://realestatevietnam.com.vn/market/ realestatevietnam at https://realestatevietnam.com.vn seorankservices A website like www.allhardscapes.com will provide you with the highest quality in the industry. Search Engine Optimization in Mississauga