Jump to content

Installing a PHP banner system


Guest saturnnights

Recommended Posts

Guest saturnnights

I have phpadsnew with Fantastico! so I've decided to give it a try...

After creating the ad campaigns and configuring it, it generates code that I'm supposed to drop into my page:

<?php

if (@include(getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php')) {

if (!isset($phpAds_context)) $phpAds_context = array();

$phpAds_raw = view_raw ('zone:1', 0, '', '', '0', $phpAds_context);

echo $phpAds_raw['html'];

}

?>

Okay, I've put this into my index.tpl, at the bottom, after </div> and before </html> and nothing happens. I'm guessing here that the code (posted above) is missing something? What could it be? Tags of some sort?

Many thanks!

Mark

Link to comment
Share on other sites

Guest groovejuice

php code must be in a file with the extension .php for it to be parsed. I haven't tried this, but perhaps start looking at index.php in your store.

Link to comment
Share on other sites

You can embed html in php files, and you can embed php in html files, but you can't embed php in.tpl files.

I've seen others trying similar things, maybe with a search you can find some of those threads. Perhaps someone was able to fix it. As a last resort, you may be able to hire a programmer or coax one to help you over at cubecart.org forum.

Link to comment
Share on other sites

Guest saturnnights

Okay, thanks for the info... I guess I should just wait to see if this is included in the next upgrade...

This is the one feature of ZenCart that I miss (from when I was demoing it). Mind you, I hate the rest of ZenCart, but they had banner options galore...

Thanks,

Mark

Link to comment
Share on other sites

You shouldnt wait on upgrade, only you need is parse YOUR $phpAds_raw['html'] to a template 'variable'. It could be a global index.tpl.

You have to manage a good place - header content usually ;)

Example:

<?php

if (@include(getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php')) {

if (!isset($phpAds_context)) $phpAds_context = array();

$phpAds_raw = view_raw ('zone:1', 0, '', '', '0', $phpAds_context);

$body->assign("BANNER", $phpAds_raw['html']);

}

?>
Add code above just after
$body = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/global/index.tpl");

in index.php (cart.php)

Then you have to find right place in header area in your global template index.tpl, {cart.tpl) (skins/{your skin}/styleTemplates/global/index.tpl) for your {BANNER} template variable.

Link to comment
Share on other sites

Guest saturnnights

Wow - I need to go have some dinner and then re-read that post! My blood sugar must be low ;)

Anyway, let me look it over and see if I can figure it out and then give it a try...

Thanks,

Mark

Link to comment
Share on other sites

Guest saturnnights

You shouldnt wait on upgrade, only you need is parse YOUR $phpAds_raw['html'] to a template 'variable'. It could be a global index.tpl.

You have to manage a good place - header content usually :D

Example:

<?php

if (@include(getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php')) {

if (!isset($phpAds_context)) $phpAds_context = array();

$phpAds_raw = view_raw ('zone:1', 0, '', '', '0', $phpAds_context);

$body->assign("BANNER", $phpAds_raw['html']);

}

?>
Add code above just after
$body = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/global/index.tpl");

in index.php (cart.php)

Then you have to find right place in header area in your global template index.tpl, {cart.tpl) (skins/{your skin}/styleTemplates/global/index.tpl) for your {BANNER} template variable.

Okay, so I should put the code above (that you modified from the original) after the piece of code you specified (in both index.php and cart.php).

Then, insert {BANNER} into my /global/index.tpl and this will display my banner? Ideally, I'd like the banner to display at the bottom of the page. Would this be as simple as putting the {BANNER} at the bottom, next to the {SITE_DOCS} ?

Sorry if I sound confused :)

Thanks!

Mark

Link to comment
Share on other sites

Guest willdashwood

I've just tried doing that today too but I get:

Fatal error: Call to a member function on a non-object in C:\apache2triad\htdocs\public_html\cubecart\index.php on line 91

Only just started playing around so will keep trying.

Edit:

My bad, forgot to place code AFTER

$body = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/global/index.tpl");

hasn't displayed a banner but then I'm not sure I've set up phpAdsNew correctly yet.

Link to comment
Share on other sites

Guest willdashwood

Got it working but I've come to the conclusion that it's probably way beyond the requirements of my client and will take too long to get to grips with. Does anyone know of a basic banner management script that allows users to add their own banners rather than going through the admin each time?

Link to comment
Share on other sites

Guest saturnnights

Well, my first attempt said that there was an error in index.php right at the line where I'd inserted this :w00t:

I'm not sure if I'll be able to get this working, but I'll give it some more thought...

Link to comment
Share on other sites

Guest saturnnights

D'oah!

I got it - had to use another version of the automatically-generated code... Now I'm 95% done - just need to center it...

What I have is a javascript version and not just a php one - I don't know exactly what I'm talking about, but on a whim, I started plugging things in and it just works! So, what is the code to format my banner? It's a script right before </body>

I know it has "center" in it... :w00t:

Link to comment
Share on other sites

Guest saturnnights

@saturnnights

I see you solved banner issue. Welcome to the World of CubeCart modifications. :w00t:

Yes! Look out - next thing you know I'll be selling skins :D

Not!!

But I am learning a lot from you all - thanks for your help!

Mark

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...