1
Ana_T
Passing variables to a block
  • 2004/8/2 21:22

  • Ana_T

  • Just popping in

  • Posts: 8

  • Since: 2004/7/30


[I changed the subject - was: Problems in integrating phpAdsNew]

Hi everyone,

anybody working with phpAdsNew?
How can I assign the variable "$phpAds_raw['html']" to my XOOPS-environment? I'm trying to integrate phpAdsNew into XOOPS and I just don't know where and how to "assign the variable" as described in the phpAdsNew-manual.

At the moment, the structure is as follows: I'm calling <{$xoops_banner}> in my theme.html which is assigned to the function "get_ads()" in the header.php, and the function "get_ads()" contains the code generated by phpAdsNew.
But it seems like I've got to use a variable because if I don't, the banner is printed as the first thing on the page...

I would be really grateful if anybody could help me out with this one...

Thanks for your help!

Ana_T

2
Ana_T
Re: Problems in integrating phpAdsNew
  • 2004/8/3 12:19

  • Ana_T

  • Just popping in

  • Posts: 8

  • Since: 2004/7/30


I solved it - found the answer in the following thread which deals with passing variables to theme.html: https://xoops.org/modules/newbb/viewtopic.php?topic_id=22912&forum=7

3
Ana_T
Integrating phpAdsNew: passing a variable to a block
  • 2004/8/3 14:17

  • Ana_T

  • Just popping in

  • Posts: 8

  • Since: 2004/7/30


Ok, I found out how to pass the variable to theme.html which solves my problem for the header. But I also need to show ads in the blocks, and I cant' find out how to pass a variable to the block. If I do it the same way as for theme.html, assigning it in the header.php like this:

$getAds_button = $phpAds_raw3['html'];
$xoopsTpl->assign('getAds_button', $getAds_button);

and then print <{$getAds_button}> in the block as HTML, it just returns <{$getAds_button}> as text. If I just define

$getAds_button = $phpAds_raw3['html'];

and then print echo $getAds_button in the block as PHP, I only get an empty block...

So the question is: how can I assing the variable $phpAds_raw3['html'] to a specific block?

Any help would be very much appreciated!!!!

Thanks a lot!
Ana_T

4
wtravel
Re: Integrating phpAdsNew: passing a variable to a block

I am not that experienced with block but when I create a new module I can add blocks through the module install where in the xoops_version.php file the block templates are related to the block php files.

On install (or update), this relationship is added to the database. Each time you call a block template for which a related php file exists, the php file is called.

So I think you should add is as part of one of the modules you use.

Please keep us updated on the progress on integration. I use phpAdsNew as well, but only directly in the theme, not through xoops_banner.

Regards,

Martijn

5
Ana_T
Re: Integrating phpAdsNew: passing a variable to a block
  • 2004/8/3 20:20

  • Ana_T

  • Just popping in

  • Posts: 8

  • Since: 2004/7/30


Still searching for a solution... As proposed, now I tried to hack the systems module (in some other thread someone proposed the systems module for this) and add a block as part of the module. Unfortunately I don't have any idea if this could be working, because the block is not shown anywhere. Anybody's got an idea why?

This is what I did:

I added the following in the system xoops_version.php

$modversion['blocks'][13]['file'] = "werbung_button.php";
$modversion['blocks'][13]['name'] = "Werbung";
$modversion['blocks'][13]['description'] = "Button-Werbung aus phpAdsNew";
$modversion['blocks'][13]['show_func'] = "getAds_button";
$modversion['blocks'][13]['template'] = 'system_block_button.html';


Then I created the file werbung_button.php with the following function:

function getAds_button()
{
   if (@include(
getenv('DOCUMENT_ROOT').'/xoops/html/modules/phpAdsNew/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw3 view_raw ('zone:3'0'_blank''''0'$phpAds_context);
        
$phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw3['bannerid']);
   }
        
$block = array();
        
$block['ads'] = $phpAds_raw3['html'];
        return 
$block;
}

?>


Finally I created the file system_block_button.html with the following content:

<div style="text-align: center;">
<{
$block}>
div>


I uploaded all files, updated the module in the system administration and changed the permissions in the groups section, giving anonymous users group rights for the created block - but still: the block is not shown... Did I forget anything???

Thanks for your help!!!!

Ana_T

6
Dave_L
Re: Integrating phpAdsNew: passing a variable to a block
  • 2004/8/3 21:26

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Quote:
But I also need to show ads in the blocks


Which blocks?

7
wtravel
Re: Integrating phpAdsNew: passing a variable to a block

A block is not showing when the php file is incorrect, so that may be one possible cause. Another possibility is that the block is not set to be visible yet (you can check in the blocks section).

Regards,

Martijn

8
Ana_T
Re: Integrating phpAdsNew: passing a variable to a block
  • 2004/8/4 10:07

  • Ana_T

  • Just popping in

  • Posts: 8

  • Since: 2004/7/30


@Dave_L: I want to create my own blocks (left/right) which then except for the title should contain only the ad.

@wtravel: I also checked if it is set as visible. I'll check the php next...

Ana_T

9
Ana_T
Re: Integrating phpAdsNew: passing a variable to a block
  • 2004/8/16 19:28

  • Ana_T

  • Just popping in

  • Posts: 8

  • Since: 2004/7/30


just to keep you informed and to thank everyone for your help: the block I hacked is showing now and the phpAdsNew-integration is working. I still don't know what the problem was with the systems block, somehow it seems to have been generated twice and the second one is working... But to be honest, I didn't try to figure out where the problem was once it was working ... .

Thanks again for your help!!!!

Ana_T

Login

Who's Online

423 user(s) are online (121 user(s) are browsing Support Forums)


Members: 0


Guests: 423


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits