Search code examples
javascriptphpyiiads

How can I add advertisement script inside yii framework loop?


I am trying to add an horizontal ad in between the content. An example article of my website is: http://articlefirm.com/biography/penny-taylor-age-net-worth-biography-twitter.html. I would like the ad to come somewhere inside the content.

The website is on YII framework. Here's the content code:

<?php echo $page->detail; ?>

Please let me know how could I add script inside the above given code.


Solution

  • you can change your main.php layout and add the code for show the ads as you like this way

    if you need pass some php vars to the main.php layout

    a simple way is add property to your controller

     class YourController extends CController {
    
        public $myParam;
    

    then assign in your action the values you need for params

    eg:

     $this->myParam ='my_adv';
    

    and then in your layout you can simple

    <?php echo $this->myParam; ?>
    

    otherwise if you don't need pass params form controller/action

    you can simply change you views/layouts/main.php

    adding the conde you need

    <?php 
    
      echo 'here i cand add  the adv i need before the view content'; 
    ?>
    
    <?php echo $content; ?>