Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> array include?
qoqo
post
Post #1





Grupa: Zarejestrowani
Postów: 53
Pomógł: 0
Dołączył: 5.06.2014

Ostrzeżenie: (0%)
-----


Witam. Chcę w pewnym znanym CMS'ie wyświetlać reklamy między postami.

Mam taką modyfikację:



  1.  
  2. <?php
  3. /*
  4. Key = Position of the Ad
  5. Value = The AdSense Banner Code
  6. */
  7. $advertisements = array('3' => '<!-- adsense ad code 1 here -->',
  8. '6' => '<!-- adsense ad code 2 here -->',
  9. '9' => '<!-- adsense ad code 3 here -->');
  10.  
  11. $i = 1;
  12.  
  13. while (have_posts()) : the_post();
  14. ?>
  15.  
  16. <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
  17. <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
  18. <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
  19.  
  20. <div class="entry">
  21. <?php the_content('Read the rest of this entry &raquo;'); ?>
  22. </div>
  23.  
  24. <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments ť', '1 Comment ť', '% Comments ť'); ?></p>
  25. </div>
  26.  
  27. <?php
  28. if(array_key_exists($i, $advertisements)) {
  29.  
  30. // you can add custom HTML code here
  31. echo $advertisements[$i];
  32. }
  33.  
  34. $i++;
  35.  
  36. endwhile;
  37. ?>
  38.  
  39.  
  40.  



Wyświetla się wszystko w porządku. Natomiast problemem jest, jeżeli chcę zaincludować plik z daną reklamą.

Czyli chodzi o to:

  1. $advertisements = array('3' => '<!-- adsense ad code 1 here -->',
  2. '6' => '<!-- adsense ad code 2 here -->',
  3. '9' => '<!-- adsense ad code 3 here -->');


W jaki sposób mogę w miejscu np.
'<!-- adsense ad code 1 here -->', includować jakiś plik?

Czy może będzie jakieś inne rozwiązanie zastępujące array?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.09.2025 - 10:26