Support Forum

Adding a simple php call

CR crewvacancies
crewvacancies
Member

Hi guys, im trying to add am ad code similar to:

<?php if( function_exists( 'pro_ad_display_adzone' ) ) echo pro_ad_display_adzone( 9 ); ?>

to the “post view” so under each post this will appear within the content area.

However it doesn’t matter where i try to place the code within the script i always get a blank page on the front end.

am i missing something? (i tried in spTopicView.php)

sorry for the newbi question but usually within WordPress i can simply drop this line anywhere and it will work.

thanks.

Daniel.

4 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Well start by removing the php tags from the start and end of that line of code. The template you are editing is all php so the tags are redundant and will cause an error.

CR crewvacancies
crewvacancies
Member

Thanks! worked like a charm.

but what happens when you want to align it? does that means i cant use basic div?

thanks,

Daniel.

YS Yellow Swordfish
Yellow Swordfish
Member

You can still use html if you want to. A php file can have both php AND html. If you want to add standard html then you can use a closing php tag before the html and then following the html use a start php tag. Or you can use an echo statement and keep it all as php. So – for example you could use something like:

if( function_exists( 'pro_ad_display_adzone' ) ) {
    echo '<div class="my_ad_block">';
    echo pro_ad_display_adzone( 9 );
    echo '</div>';
}

and then you could style your ‘my_ad_block’ using CSS as usual.

Don’t forget – As always we recommend that you create your own SP theme so that any customisation is not lost during a future update. (http://codex.simple-press.com/codex/themes/theme-basics/creating-a-theme/)

MP Mr Papa
Mr Papa
Member

and just to be complete and follow up with example to Andy’s comment about interspersing html and php, would be something like:

if (function_exists('pro_ad_display_adzone')) {
?>
    <div class="my_ad_block">
<?php
    echo pro_ad_display_adzone(9);
?>
    </div>
<?php
}

the <?php starts a php code section and the ?> ends it… anything outside that is html…