plugin: Hide googleAds in PDF
Written by kksou   
Monday, 16 June 2008

This plugin hides {googleAds} tags when generating PDF of your content items.

If you have installed the {googleAds} plugin, and you try to generate PDF of your content item by clicking on the PDF icon in the top right corner of your content page, you will find that the google Adsense codes will appear in the generated PDF too! This is, of course, undesirable.

This plugin will automatically hide all these {googleAds} tags and google Adsense codes in the generated PDF.


Latest Version

v1.0.1 (for Joomla 1.0) and v1.5.1 (for Joomla 1.5)
Released December 9, 2008

Fixed the warning message "Undefined variable: flag"

Download


How to install (Joomla 1.0.x)

  1. Download the plugin and unzip it into a folder.
  2. From the Installers menu, select mambots. In the field "Install directory", enter the folder location (where you unzipped the file) and click Install.
  3. From the Mambots menu, select Site Mambots.
  4. Make sure the plugin "Hide googleAds for PDF" is published. If you see a cross in the Published column, just click on it. It will turn into a green tick.
  5. To use this plugin, you need to add a trigger to the PDF generator. In the original Joomla installation, there is no trigger during the generation of PDF. When there is no trigger, none of the plugin gets called. In order for Joomla to call the new plugin that we have just installed to hide the {googleAds} tags, we need to add a trigger.
    1. Go to the folder <Joomla root folder>/includes, you will see a file called pdf.php.
    2. Open this file pdf.php in your favorite editor.
    3. Go to around line 112, and add the 6 lines highlighted in yellow as shown below:
    4. $txt1 = $row->title;
      $pdf->ezText( $txt1, 14 );
      
      $txt2 = AuthorDateLine( $row, $params );
      
      $pdf->ezText( $txt2, 8 );
      
      $txt3 = $row->introtext ."\n". $row->fulltext;
      
      global $_MAMBOTS;
      $params = array();
      $row->text = $txt3;
      $_MAMBOTS->loadBotGroup( 'content' );
      $results = $_MAMBOTS->trigger( 'onBeforeDisplayTitle', array( &$row, array(), 32) );
      $txt3 = $row->text;
      
      $pdf->ezText( $txt3, 10 );
      
      $pdf->ezStream();
      

    5. Save and close this file.

  6. Try generate PDF for your content item. It should now be clean of any {googleAds} tags!

How to install (Joomla 1.5.x)

  1. Download the plugin and unzip it into a folder.
  2. From the Extensions menu, select Install/Uninstall. In the field "Install directory", enter the folder location (where you unzipped the file) and click Install.
  3. From the Extensions menu, select Plugin Manager.
  4. Enable the plugin "Hide googleAds in PDF" - make sure there is a green tick in the Enabled column.
  5. To use this plugin, you need to add a trigger to the PDF generator. In the original Joomla installation, there is no trigger during the generation of PDF. When there is no trigger, none of the plugin gets called. In order for Joomla to call the new plugin that we have just installed to hide the {googleAds} tags, we need to add a trigger.
    1. Go to the folder <Joomla root folder>/components/com_content/views/article, you will see a file called view.pdf.php.
    2. Open this file view.pdf.php in your favorite editor.
    3. Go to around line 42, and add the 2 lines highlighted in yellow as shown below:
    4. // Initialize some variables
      $article	= & $this->get( 'Article' );
      $params 	= & $article->parameters;
      
      // process the new plugins
      JPluginHelper::importPlugin('content', 'image');
      $dispatcher->trigger('onPrepareContent', array (& $article, & $params, 0));
      
      JPluginHelper::importPlugin('content');
      $results=$dispatcher->trigger('onBeforeDisplayTitle', array(&$article, array(), 32));
      
      $document = &JFactory::getDocument();
      
      // set document information
      $document->setTitle($article->title);
      $document->setName($article->alias);
      $document->setDescription($article->metadesc);
      $document->setMetaData('keywords', $article->metakey);
      

    5. Save and close this file.

  6. Try generate PDF for your content item. It should now be clean of any {googleAds} tags!

 
< Prev   Next >

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2012. kksou.com. All Rights Reserved