PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, March 8, 2022

[FIXED] How can I add advertisement script inside yii framework loop?

 March 08, 2022     ads, javascript, php, yii     No comments   

Issue

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; ?>


Answered By - ScaisEdge
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing