Welcome to Geeklog, Anonymous Wednesday, February 05 2025 @ 11:07 pm EST

Geeklog Forums

Banner Ad in article 1 and 4


Status: offline

fakestar

Forum User
Chatty
Registered: 03/15/06
Posts: 37
Hello,

I have a doubt in how to put a banner to appear always in article 1 and 4 in front page.
If i post new article, the banner stills appearing in article number 1 and 4.

How can i make this change?

THanks!
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
In public_html/index.php is probably the only place to really do this. Find this code (this is GL v1.4.0):
Text Formatted Code
    // display first article
    $display .= STORY_renderArticle ($A, 'y');

    // get plugin center blocks after featured article
    if ($A['featured'] == 1) {
        $display .= PLG_showCenterblock (2, $page, $topic);
    }

    // get reamaining stories
    while ( $A = DB_fetchArray($result) ) {
        $display .= STORY_renderArticle ($A, 'y');
    }
 
Modify the while loop so you keep count of the number of articles rendered and call your ad function after the first and fourth articles.
 Quote

Status: offline

fakestar

Forum User
Chatty
Registered: 03/15/06
Posts: 37
Text Formatted Code

   // get reamaining stories
    while ( $A = DB_fetchArray($result) ) {
        $display .= STORY_renderArticle ($A, 'y');

if ($A == 1 OR $a ==4){
My banner code
}
    }
 


I did this modification but it doesn't work :/
Can you help me?
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
You need an independent article counter:
Text Formatted Code
     // display first article
    $display .= STORY_renderArticle ($A, 'y');

    $cnt = 0;
    // get reamaining stories
    while ( $A = DB_fetchArray($result) ) {
        ++$cnt;
        if ($cnt == 1 OR $cnt ==4){
            Your banner code
        }
        $display .= STORY_renderArticle ($A, 'y');
    }
 
 Quote

Status: offline

fakestar

Forum User
Chatty
Registered: 03/15/06
Posts: 37
Thanks again jmucchiello.

if i put "test banner" alone i get errors.
I put an echo like this:


Text Formatted Code
<br />    $cnt = 0;<br />    // get reamaining stories<br />    while ( $A = DB_fetchArray($result) ) {<br />        ++$cnt;<br />        if ($cnt == 1 OR $cnt ==4){<br />          echo  ("test banner");<br />        }<br />        $display .= STORY_renderArticle ($A, 'y');<br />    }<br /><br />


but the "test banner" shows above my header, not in article.
what am i doing wrong?
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
You never echo in Geeklog. See all the other lines that say $display .= something. You need to write $display .= MyAdFunction() where MyAdFunction returns valid HTML containing your ads.
 Quote

Status: offline

fakestar

Forum User
Chatty
Registered: 03/15/06
Posts: 37
Thank you very much, now it's working Smile

 Quote

All times are EST. The time is now 11:07 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content