Building Layout plugins for SocialAds

Layout Plugins let you create your own styles in which Ads can be displayed on your site. By Default we already provide you with 5 layout plugins. Think of Layout plugins as templates for your Ad Display. The main file of the template, layout.php defines how the various template elements viz. the Ad Title, Ad Image/ Video etc are placed with respect to one another.

With the help of this documentation you can easily create your own styles of display. Besides these docs, we recommend you look at the layout plugins that come bundles with SocialAds. The type of these plugins is socialadslayout

Plugin File Structure

  1. plug_yourpluginname.xml(file)
  2. plug_yourpluginname.php(file)
  3. plug_yourpluginname(folder)
    This folder contains 3 files
    a. layout.php(file)
    This is the file in which the layout html resides.
    b. layout.css(file)
    This should contain all the css elements that style your layout html
    c. layout.png(file)
    This can be a screenshot or representative image of the layout that is used to show a preview to the user in Ad Creation.
    This image should be 100 X 84 pixels, saved as a .png file & be named exactly as layout.png

For the Purpose of explaining how you develop a Layout plugin, we are taking the example of the  "Social Ads - Layout 1" plugin included in our Package. It is named as "plug_layout1" .

plug_yourpluginname.xml

 

                

    Social Ads - Layout 1
    TechJoomla
    Mar 2012
    Techjoomla. All Rights Reserved.
    extensionstechjoomla.com
    http://www.techjoomla.com
    http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
    2.7.3
    plugin for the layouts
    
        
        plug_layout1.php
                
        plug_layout1
    
        
    
    
                        
    
    
    
            
                

 

plug_yourpluginname.php

This is simply the entry file. You dont need to change anything here

 


layout.php

The layout.php file is the main file that you need to change to match your needs. All the Ad elements are available in thiel file in the variable $addata.The elements available are :
$addata->ad_title , $addata->ad_body, $addata->ignore, $addata->link, $addata->ad_image.

The variable $ht has the html to display for the ad. You can change this as needed.

';
if( $addata->ignore !='')
$ht .= 'altignore.'" />';
/*Ad title starts here...*/
    $ht .= '

';
/*Ad title ends here*/
/*Ad image starts here...*/
$ht.='

';
/*Ad image ends here*/
/*Ad description starts here...*/
    $ht .= '
'; $ht .=''. $addata->ad_body; $ht .='
'; /*Ad description ends here*/ $ht .='
'; echo $ht; ?>