xoops forums

olivee

Just popping in
Posted on: 2014/7/21 14:03
olivee
olivee (Show more)
Just popping in
Posts: 24
Since: 2014/1/28
#1

smarty in php file

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}>

olivee

Just popping in
Posted on: 2014/7/22 12:29
olivee
olivee (Show more)
Just popping in
Posts: 24
Since: 2014/1/28
#2

Re: smarty in php file

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

<{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}>

Mamba

Moderator
Posted on: 2014/7/22 13:44
Mamba
Mamba (Show more)
Moderator
Posts: 10799
Since: 2004/4/23
#3

Re: smarty in php file

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-var ... etween-templates-and-php/

http://stackoverflow.com/questions/88 ... -variable-within-php-tags
http://www.sitepoint.com/forums/showt ... TY-variable-into-php-code

http://dustyreagan.com/how-to-referen ... ariables-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:

$sitename=$xoopsTpl -> get_template_vars'xoops_sitename' );


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

olivee

Just popping in
Posted on: 2014/7/22 14:04
olivee
olivee (Show more)
Just popping in
Posts: 24
Since: 2014/1/28
#4

Re: smarty in php file

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.
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
<{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}>

Bleekk

Theme Designer
Posted on: 2014/7/22 18:00
Bleekk
Bleekk (Show more)
Theme Designer
Posts: 934
Since: 2002/12/14
#5

Re: smarty in php file

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

noo-b

Just can't stay away
Posted on: 2014/7/22 23:51
noo-b
noo-b (Show more)
Just can't stay away
Posts: 456
Since: 2007/10/23
#6

Re: smarty in php file

<?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");
?>

olivee

Just popping in
Posted on: 2014/7/23 14:44
olivee
olivee (Show more)
Just popping in
Posts: 24
Since: 2014/1/28
#7

Re: smarty in php file

thank you. all I need is $xoTheme

I got it

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);