1
olivee
smarty in php file
  • 2014/7/21 14:03

  • olivee

  • Just popping in

  • Posts: 24

  • Since: 2014/1/28


I need your help

I want to add a php file to xoops so I have done this
create page.php in the root of xoops.

add this code in page.php

<?php if (file_exists("mainfile.php")) { include("mainfile.php"); } include(XOOPS_ROOT_PATH."/header.php"); echo '<{$xoops_banner}>'; include(XOOPS_ROOT_PATH."/footer.php"); ?>


the problem is that <{$xoops_banner}> des not execute. so how can I do to execute default smarty code like <{$xoops_slogan}> <{$xoops_sitename}>

2
olivee
Re: smarty in php file
  • 2014/7/22 12:29

  • olivee

  • Just popping in

  • Posts: 24

  • Since: 2014/1/28


I think it is not possible to use smarty code in my case.

then I want to use php directly.

who can give me the php code for output as the left column.

in other words, have the php code that corresponds to

le="color: #000000"><?php <{if $xoops_showlblock}> <{foreach item=block from=$xoBlocks.canvas_left}> <{if $block.title}> <div class="blockTitle"><{$block.title}></div> <{/if}> <div class="blockContent"><{$block.content}></div> <{/foreach}> <{/if}>

3
Mamba
Re: smarty in php file
  • 2014/7/22 13:44

  • Mamba

  • Moderator

  • Posts: 11523

  • Since: 2004/4/23


If the Smarty variable is assigned, you should be able to use it.

I am not a Smarty guru, so I used Google and searched for "using smarty variable in php", and I got few links that I think, should help you:

http://www.saurus.info/exchanging-variables-between-templates-and-php/

http://stackoverflow.com/questions/8828210/using-smarty-variable-within-php-tags
http://www.sitepoint.com/forums/showthread.php?651886-Passing-a-SMARTY-variable-into-php-code

http://dustyreagan.com/how-to-reference-smarty-variables-inside-php-tags/

So based on the above, this is the right way to do it:

http://www.smarty.net/docsv2/en/api.get.template.vars.tpl

For example, in the fbcomment module, it is used like this:

le="color: #000000"><?php $sitename=$xoopsTpl -> get_template_vars( 'xoops_sitename' );


I hope, it helps!
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

4
olivee
Re: smarty in php file
  • 2014/7/22 14:04

  • olivee

  • Just popping in

  • Posts: 24

  • Since: 2014/1/28


mamba thank you for the answer.
thank you for the links. in my case it is different. does not play with smarty, the solution is to use php directly.
le="color: #000000"><?php echo '<{$xoops_slogan}> => "'.htmlspecialchars($GLOBALS['xoopsConfig']['slogan'], ENT_QUOTES).'"'; <{$xoops_sitename}> - "'.htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES).'"


My problem now is to find the php code that generates the blocks. left center and right column.
have you a pist for this
le="color: #000000"><?php <{if $xoops_showlblock}> <{foreach item=block from=$xoBlocks.canvas_left}> <{if $block.title}> <div class="blockTitle"><{$block.title}></div> <{/if}> <div class="blockContent"><{$block.content}></div> <{/foreach}> <{/if}>


5
Bleekk
Re: smarty in php file
  • 2014/7/22 18:00

  • Bleekk

  • Theme Designer

  • Posts: 942

  • Since: 2002/12/14


Therewas a blank module somewhere in the download section. Take it, rename it and you will have also the side columns and blocks

6
noo-b
Re: smarty in php file
  • 2014/7/22 23:51

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


<?php // Author: Trabis // URL: http://www.xuups.com // E-Mail: lusopoemas@gmail.com include("../../mainfile.php"); include(XOOPS_ROOT_PATH."/header.php"); $meta_keywords = "dummy, page, keywords"; $meta_description = "dummy page description"; $pagetitle = "dummy page title"; if(isset($xoTheme) && is_object($xoTheme)) { $xoTheme->addMeta( 'meta', 'keywords', $meta_keywords); $xoTheme->addMeta( 'meta', 'description', $meta_description); } else { // Compatibility for old Xoops versions $xoopsTpl->assign('xoops_meta_keywords', $meta_keywords); $xoopsTpl->assign('xoops_meta_description', $meta_description); } $xoopsTpl->assign('xoops_pagetitle', $pagetitle); //this will only work if your theme is using this smarty variables $xoopsTpl->assign( 'xoops_showlblock', 1); //set to 0 to hide left blocks $xoopsTpl->assign( 'xoops_showrblock', 1); //set to 0 to hide right blocks $xoopsTpl->assign( 'xoops_showcblock', 1); //set to 0 to hide center blocks ?>  <!--DUMMY HTML CONTENT--> <?php include(XOOPS_ROOT_PATH."/footer.php"); ?>

7
olivee
Re: smarty in php file
  • 2014/7/23 14:44

  • olivee

  • Just popping in

  • Posts: 24

  • Since: 2014/1/28


thank you. all I need is $xoTheme

I got it

le="color: #000000"><?php if ($xoTheme->template->_tpl_vars['xoops_showlblock']): $_from = $xoTheme->template->_tpl_vars['xoBlocks']['canvas_left']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)): foreach ($_from as $xoTheme->template->_tpl_vars['block'] => $kex): echo $kex["content"]; endforeach; endif; unset($_from); endif; if ($xoTheme->template->_tpl_vars['xoBlocks']['page_topleft'] || $xoTheme->template->_tpl_vars['xoBlocks']['page_topcenter'] || $xoTheme->template->_tpl_vars['xoBlocks']['page_topright']): $_from = $xoTheme->template->_tpl_vars['xoBlocks']['page_topcenter']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)): foreach ($_from as $xoTheme->template->_tpl_vars['block'] => $kex): echo $kex["content"]; endforeach; endif; unset($_from);

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