1
cmsguy
Accessing $XOOPS Variables In Custom Blocks
  • 2004/3/9 6:15

  • cmsguy

  • Just popping in

  • Posts: 31

  • Since: 2004/3/3 2


Can I create a custom block that includes various variables such as ${xoops_url} and so on?

I am having trouble doing this. Is it because custom blocks are not system blocks?

Thanks.

2
hsalazar
Re: Accessing $XOOPS Variables In Custom Blocks
  • 2004/3/9 6:37

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


cmsguy:

You can. Just have in mind that when writing a custom block, you're coding in PHP. This means that instead of having variables such as <{$xoops_url}> (please notice the dollar sign is inside the curly brackets), you should use variables such as XOOPS_ROOT_PATH. For instance:

$something = XOOPS_ROOT_PATH."/modules/name/index.php?id=".$var;

Cheers.

3
cmsguy
Re: Accessing $XOOPS Variables In Custom Blocks
  • 2004/3/9 7:49

  • cmsguy

  • Just popping in

  • Posts: 31

  • Since: 2004/3/3 2


Thanks for the tip. I understand mostly.

How could I access language the same way the main menu does?

MAIN MENU SYSTEM BLOCK

<td id="mainmenu">
<a class="menuTop" href="<{$xoops_url}>/"><{$block.lang_home}></a>
<!-- start module menu loop -->
<{foreach item=module from=$block.modules}>
<a class="menuMain" href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}></a>
<{foreach item=sublink from=$module.sublinks}>
<a class="menuSub" href="<{$sublink.url}>"><{$sublink.name}></a>
<{/foreach}>
<{/foreach}>

COULD I ACCESS ALL OF THESE VARIABLES IN A CUSTOM BLOCK?


Thanks again.

4
Herko
Re: Accessing $XOOPS Variables In Custom Blocks
  • 2004/3/9 8:25

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


In short: no. As you see, some of these vatiables, are specific to this main menu block. Thus, they cannot be called in another block.

<{$xoopsurl}> is a site wide smarty variable, but a custom block made through the block admin page is not a smarty template. You cannot use those Smarty variables in that custom block. You can add php code however, and HTML.

Horacio meant that when you're creating a real custom block, and add it to the module you want to use it in, you'll have to create a new PHP file with the block generation and moderation code, the xoops_version.php file (defining the block), and the template file. In that template file you can use Smarty variables.

So, basically, there are two options: a basic one with the blocks admin page, where you can use the XOOPS_URL variable as Horacio described, or your own php code, or you have the more advanced option, where you actually code a full complete new block and add it to a module (thus extending the existing module).

Herko

5
Sm0ka
Re: Accessing $XOOPS Variables In Custom Blocks
  • 2004/3/9 8:52

  • Sm0ka

  • Just popping in

  • Posts: 41

  • Since: 2003/12/25


hmmm... wouldn't it be great if there was a file with the smarty variables and their correspondents in block allowed variables? Or maybe open up a wiki for this?
Just an idea as it would be good for us rookies to access this on a simple way.

6
cmsguy
Re: Accessing $XOOPS Variables In Custom Blocks
  • 2004/3/12 4:51

  • cmsguy

  • Just popping in

  • Posts: 31

  • Since: 2004/3/3 2


I tried your second suggestion by adding a new module with it's own block. The new module and block is based on the sample_module available withn the forum. I added the following main menu code to the sample_filename.html file under the sample_module/template/block directory. It did not work probably because the new module and block do not have access to the MAIN MENU smarty variables (I am assuming this! )such as $xoops_url, $block.lang.home etc ...

MAIN MENU SYSTEM BLOCK

<td id="mainmenu">
<a class="menuTop" href="<{$xoops_url}>/"><{$block.lang_home}></a>
<!-- start module menu loop -->
<{foreach item=module from=$block.modules}>
<a class="menuMain" href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}></a>
<{foreach item=sublink from=$module.sublinks}>
<a class="menuSub" href="<{$sublink.url}>"><{$sublink.name}></a>
<{/foreach}>
<{/foreach}>

I AM OBVIOUSLY MISSING A CONCEPT HERE!

Will my new main menu block only work if I add it to the system module?

If so, does this mean I would have to redefine these smarty variable in my new module?

How can I create a new module and associated block and have them be able to access the system smarty common variables?

Confused, but thankful for any help.

Login

Donat-O-Meter

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

Latest GitHub Commits