A A A

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Hooks, Return, Echo, Oh My
Jul 14, 2010
2:16 am
Member
Forum Posts: 50
Member Since:
Jan 1, 2008
Offline

Let me preface this by saying that I couldn't write a line of code to save my life. :)

I'm using an online banner ad provider and they gave me this line of code to insert onto my page to display the banner ad:

<?php if(function_exists('oiopub_banner_zone')) oiopub_banner_zone(1,
'center'); ?>

So after searching this forum I saw over and over to read the Wiki for the API Hooks so I did that. And I read about 10 various threads. And I read about don't use "Echo" use "Return." The problem is I don't know what that means…see above reference to not knowing how to code… :)

But I'm giving it the old college try, and I tried editing the sf-hook-template.txt file and saving it as a php file. Here's the hook I edited:

function sf_hook_post_content()
    {
        return '<?php if(function_exists('oiopub_banner_zone')) oiopub_banner_zone(1, 'center'); ?>';
    }

See? I tried! But it's not working. I'm getting this error:

Parse error: syntax error, unexpected T_STRING in /home/ispwpcom/public_html/wp-content/plugins/simple-forum/forum/hooks/sf-hook-template.php
on line 68

And of course line 68 is the line I edited.

What am I doing wrong?

Jul 14, 2010
4:16 am

SP Master
Forum Posts: 22186
Member Since:
Nov 9, 2008
Offline

Two things. Although it depends what that function is doing.

One – you may not need the single quote either end – but you might! The problem is we do not know what is being sent back by that function until we try it. So I would leave them out to start with. But if they are needed, you can't do them quite like that.

Two – You are already within a php block so you do not need the php tags.

I can not say this will work properly because I do not know what to expect from that function but something this is your first try:

function sf_hook_post_content()
{
    if(function_exists('oiopub_banner_zone'))
    {
        return oiopub_banner_zone(1, 'center');
    }
}

See if that works.

Yellow Swordfish
Jul 14, 2010
4:39 am
Member
Forum Posts: 50
Member Since:
Jan 1, 2008
Offline

Hmmm… Well the good news is that it's not giving error messages anymore and the forum is displaying properly.

The bad news is that the banner ad isn't displaying.

 

They do provide a javascript code snippet as a substitute:

<script type='text/javascript'
src='http://www.ispwp.com/oiopub/js…..pt&gt;

 

But I tried sticking that in the php file in a number of different ways and can't get that to work either.

Jul 14, 2010
4:58 am

SP Master
Forum Posts: 22186
Member Since:
Nov 9, 2008
Offline

Well before changing it – were there no more instructions or useful information? Like of echo was needed or if the function did it's own echo (for example).

And… is that function actually loaded somewhere? Did it come in a plugin fr example?

Yellow Swordfish
Jul 14, 2010
5:06 am
Member
Forum Posts: 50
Member Since:
Jan 1, 2008
Offline

I'm not sure if this is helpful, but this is all I could find regarding the instructions.

 

To integrate OIOpublisher with a 3rd party website:

(1) PHP Integration Code:
If you want to integrate OIOpublisher into an existing website, you'll need to add a line of php code to your site. You'll then be able to use the php output functions to show ads (otherwise, you'll need to use javascript)
<?php include_once('/home/ispwpcom/public_html/oiopub/index.php'); ?>

(2) Theme Hooks PHP Code:
To complete php integration with your website, you can add header and footer hooks code to your site. This will save you having to make manual code edits to your website template files in the future.
<?php if(function_exists('oiopub_header')) oiopub_header(); ?>
put this above the </head> tag
<?php if(function_exists('oiopub_footer')) oiopub_footer(); ?>
put this above the </body> tag

To display banner ad code on your website:

(1) Using Javascript:
Place this javascript code on any website you want to display ads on. Remember to replace 'X' with the zone number you want to show.
<script type='text/javascript' src='http://www.ispwp.com/oiopub/js…..pt&gt;

(2) Using PHP:
You must have completed the 3rd party website integration steps to use php output code.
<?php if(function_exists('oiopub_banner_zone')) oiopub_banner_zone(1, 'center'); ?>

Jul 14, 2010
6:37 am

SP Master
Forum Posts: 22186
Member Since:
Nov 9, 2008
Offline

and did you put those header and footer code in place?
And you didn't tell me if this comes as a plugin?

Yellow Swordfish
Mar 30, 2011
1:17 am
Member
Forum Posts: 18
Member Since:
Dec 17, 2009
Offline

I'm trying to post an affiliate banner on my forum. Like many others, I have gone to the wiki to read about hooks and how to use them, but I'm apparently missing something.

Here is the affiliate code:

<a target="_blank" href="http://www.shareasale.com/r.cfm?b=284156&u=212812&m=30819&urllink=&afftrack="><img src="http://www.shareasale.com/image/30819/180x150_03.jpg"  border="0"></a>

Let's say I want to use the sf_hook_pre_content()

 

Would it look like this?

 

function sf_hook_pre_content()
    {
        return '<a target="_blank"
href="http://www.shareasale.com/r.cfm?b=284156&u=212812&m=30819&urllink=&afftrack="><img
src="http://www.shareasale.com/image/30819/180x150_03.jpg" 
border="0"></a>';

    }

After entering that, I uploaded the modified .txt file to the server and renamed sf-hook-template.txt to a .php file. Nothing happened on my forum. As far as I could tell, nothing was different. What am I missing?

Mar 30, 2011
4:24 am

SP Master
Forum Posts: 22186
Member Since:
Nov 9, 2008
Offline

At first sight it look good to me – I can't speak for the legitimacy of the query variables or urls of course but the code itself is in the correct condition.

First check forum admin > Configuration > Storage Locations to ensure your program hooks location is pointing to the correct folder where the file is.

Assuming it is correct take a look at the source being generated in the browser and search for that bit of code – say the image. That will tell us if it is indeed being generated. if you use Firefox and if there is any error in the urls or tags it will usually show up in red so that's another thing to look for.

Let us know what you find…

Yellow Swordfish
Forum Timezone: America/Chicago

Most Users Ever Online: 444

Currently Online: Jason Clark, Superfast
72 Guest(s)

Currently Browsing this Page:
1 Guest(s)

See All Online Activity

Top Posters:

-Radio-: 1251

Lee H: 606

Luffer: 535

Conrad_Farlow: 501

jim: 478

neon: 263

ovizii: 240

Tal: 240

Member Stats:

Guest Posters: 2624

Members: 7354

Moderators: 1

Admins: 2

Forum Stats:

Groups: 5

Forums: 16

Topics: 10877

Posts: 79454

Moderators: Brandon C (162)

Administrators: Yellow Swordfish (22180), Mr Papa (23688)