Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Adding a simple php call
Avatar
crewvacancies
Worldwide
Member
Free Members
sp_UserOfflineSmall Offline
Jun 11, 2012 - 10:39 am

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.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 11, 2012 - 10:52 am

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.

andy-signature.png
YELLOW
SWORDFISH
Avatar
crewvacancies
Worldwide
Member
Free Members
sp_UserOfflineSmall Offline
Jun 11, 2012 - 11:01 am

Thanks! worked like a charm.

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

thanks,

Daniel.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 11, 2012 - 11:26 am

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/.....g-a-theme/)

andy-signature.png
YELLOW
SWORDFISH
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jun 11, 2012 - 9:59 pm

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...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 643
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 616
Members: 17343
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10117
Posts: 79590