Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Sidebars & Widgets (http://forum.bytesforall.com/forumdisplay.php?f=14)
-   -   Dynamic Ads into Widget - How? (http://forum.bytesforall.com/showthread.php?t=18259)

Regist Aug 27, 2012 02:19 PM

Dynamic Ads into Widget - How?
 
Hi!

My site is http://multivarkavari.ru/
WordPress 3.1.2.
Atahualpa 3.6.7 (thanks! :)).

And my question is about widget with ads in right up corner of site.
I want that each time the different advertizing chosen in a random way there was shown.
For this purpose I have a php function but where it to insert?

Thanks!

lmilesw Aug 27, 2012 02:43 PM

There are plugins that give you widgets you can put php code in. If you want the widget in the top of the site you may have to add a new widget area per the instructions in the Add New Widget Area section of the theme options.

Regist Aug 28, 2012 12:11 AM

Yes, I went this way (using plugin PHP Code Widget), but for some reason the code doesn't work, advertizing isn't shown

If I simply insert a code into a simplt text widget
--------
<!-- Яндекс.Директ --><script type="text/javascript">yandex_partner_id = 84403;yandex_site_bg_color = 'FFFFFF';yandex_site_charset = 'utf-8';yandex_ad_format = 'direct';yandex_direct_type = '180x150';yandex_direct_border_type = 'block';yandex_direct_border_radius = true;yandex_direct_header_bg_color = 'CC6666';yandex_direct_bg_color = 'FFCCCC';yandex_direct_border_color = 'CC6666';yandex_direct_title_color = '990000';yandex_direct_url_color = '990000';yandex_direct_text_color = '000000';yandex_direct_hover_color = 'CC6666';yandex_direct_favicon = true;document.write('<sc'+'ript type="text/javascript" src="http://an.yandex.ru/system/context.js"></sc'+'ript>');</script>
--------
This works (rose ads in up rigth sidebar).

But if i'm insert into php code widget
--------------
<?php
return '<div id="market"><!-- Яндекс.Маркет -->
<script type="text/javascript">
yandex_partner_id = 84403;
yandex_site_bg_color = \'FFFFFF\';
yandex_stat_id = 3;
yandex_site_charset = \'utf-8\';
yandex_ad_format = \'direct\';
yandex_direct_type = \'180x150\';
yandex_direct_header_bg_color = \'CC6666\';
yandex_direct_bg_color = \'FFCCCC\';
yandex_direct_title_color = \'990000\';
yandex_direct_url_color = \'990000\';
yandex_direct_text_color = \'000000\';
yandex_direct_hover_color = \'CC6666\';
yandex_direct_favicon = true;
document.write(\'<sc\'+\'ript type="text/javascript" src="http://an.yandex.ru/system/context.js"></sc\'+\'ript>\');
</script></div>';
>
--------------
this doesn't works! :(

Is given to me, I do something incorrectly!
What?

juggledad Aug 28, 2012 03:15 AM

ou don't have a closing '?>' but you don't need to use PHP in anycase, try
HTML Code:

<div id="market"><!-- Яндекс.Маркет -->
<script type="text/javascript">
yandex_partner_id = 84403;
yandex_site_bg_color = \'FFFFFF\';
yandex_stat_id = 3;
yandex_site_charset = \'utf-8\';
yandex_ad_format = \'direct\';
yandex_direct_type = \'180x150\';
yandex_direct_header_bg_color = \'CC6666\';
yandex_direct_bg_color = \'FFCCCC\';
yandex_direct_title_color = \'990000\';
yandex_direct_url_color = \'990000\';
yandex_direct_text_color = \'000000\';
yandex_direct_hover_color = \'CC6666\';
yandex_direct_favicon = true;
document.write(\'<sc\'+\'ript type="text/javascript" src="http://an.yandex.ru/system/context.js"></sc\'+\'ript>\');
</script></div>


Regist Aug 28, 2012 03:47 PM

I need to realize the following:
$x=rand (1,5);

and then, depending on x to show
either advertizing 1, or advertizing 2 etc.

But when I tried to realize it by means of php, inserting a code into a widget, found out that it doesn't work.
Debugging function I cleaned code slices, yet it was not necessary simply - to deduce continuous advertizing, but by means of php. It doesn't work.

It is not obligatory to me to do it on php, it is simple as then it is possible to realize it - to alternate advertizing in a widget in a random way?

juggledad Aug 28, 2012 04:25 PM

if you are displaying an ad based on a random number, then yes you need to do it using PHP.
Just remember you have to have your syntax correct in order for it to work.

Regist Aug 29, 2012 02:49 AM

Oh, this code in PHP Code Widget doesn't working! :(

HTML Code:

<?php
 return '<div id="market"><!-- Яндекс.Маркет -->
 <script type="text/javascript">
 yandex_partner_id = 84403;
 yandex_site_bg_color = \'FFFFFF\';
 yandex_stat_id = 3;
 yandex_site_charset = \'utf-8\';
 yandex_ad_format = \'direct\';
 yandex_direct_type = \'180x150\';
 yandex_direct_header_bg_color = \'CC6666\';
 yandex_direct_bg_color = \'FFCCCC\';
 yandex_direct_title_color = \'990000\';
 yandex_direct_url_color = \'990000\';
 yandex_direct_text_color = \'000000\';
 yandex_direct_hover_color = \'CC6666\';
 yandex_direct_favicon = true;
 document.write(\'<sc\'+\'ript type="text/javascript" src="http://an.yandex.ru/system/context.js">
</sc\'+\'ript>\');
 </script></div>';
?>

Widget is viewing nothing!

Maybe, this code returned string with code, but this string must be executing!
But how do this?

juggledad Aug 29, 2012 06:10 AM

try this
HTML Code:

<?php // start of my php - but now I need to switch back to HTML
?>

<div id="market"><!-- Яндекс.Маркет -->
<script type="text/javascript">
 yandex_partner_id = 84403;
 yandex_site_bg_color = \'FFFFFF\';
 yandex_stat_id = 3;
 yandex_site_charset = \'utf-8\';
 yandex_ad_format = \'direct\';
 yandex_direct_type = \'180x150\';
 yandex_direct_header_bg_color = \'CC6666\';
 yandex_direct_bg_color = \'FFCCCC\';
 yandex_direct_title_color = \'990000\';
 yandex_direct_url_color = \'990000\';
 yandex_direct_text_color = \'000000\';
 yandex_direct_hover_color = \'CC6666\';
 yandex_direct_favicon = true;
 document.write(\'<sc\'+\'ript type="text/javascript" src="http://an.yandex.ru/system/context.js"></sc\'+\'ript>\');
 </script></div>
?<php // ok, now I am back in php
return;
?>


Regist Aug 29, 2012 12:43 PM

the php code widget with this code deduces '?'

juggledad Aug 29, 2012 12:53 PM

it doesn't deduce anything - if you want it to display different ads based on a random number, you need to code the routine that generates the random number, code to test it and display the approperate ad.

I would suggest creating the PHP code and testing it with just printing a word for each case. once you get it working, then you can add the ad code in.


All times are GMT -6. The time now is 10:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.