开发者

What is this syntax and how to debug it?

I am currently working on moving an expression engine site from one server to another and i noticed one issue i am having a hardtime debugging. When i upload an logo image all seems fine but the index.php page that the logo is displayed on it has this code

{embed="shared/head"}

<body class="{if segment_1 == ''}home{if:else}{segment_1}{/if}">

    <div id="page" class="container">
        <div class="span-22 prepend-1 append-1 last">

            {embed="shared/masthead"}
{if logo !=''}
  <div class="news_item_logo">
    {organization}
      {if link}<a href="http://{exp:php_text_format type="lowercase"}{if url !=''}{url}{if:else}{name}{/if}{/exp:php_text_format}"><img src="{logo}" width="130" alt="{title}" /></a>{if:else}
      <img src="{logo}" width="130" alt="{开发者_开发问答title}" />{/if}
    {/organization}
  </div><!-- /.news_item_logo -->
  <ul>
    <li><h3>{title}</h3></li>
    <li>{pub_date}</li>
  {organization}
    <li>{if link}<a href="http://{if url !=''}{url}{if:else}{name}{/if}">{/if}{exp:php_text_format type="lowercase"}{if url_text != ''}{url_text}{if:else}{name}{/if}{if link}{/exp:php_text_format}</a>{/if}</li>
  {/organization}
    <li>{if file}<a href="{site_url}{file}">PDF</a>{/if}{if web_link !='' AND file !=''}&nbsp;&nbsp;|&nbsp;&nbsp;{/if}{if web_link}<a href="{web_link}">HTML</a>{/if}</li>
  </ul>
{if:else}
  <ul class="no_logo">
    <li><h3><a href="{web_link}">{title}</a></h3></li>

My question is this, I see curly brackets {} around if statements and i want to know first what language it is and second is there a way to debug like php print_r() because the code always goes to the else with the no_logo class and i want to know what and how i can test these variables "segment1" and "logo" and "organization" and "url" How do and where do i inspect these variables


You can gain some info about the given variables and values in the template using the following within your index.php:

<?php

$EE = get_instance();
var_dump($this->EE->TMPL);

?>

Note that PHP must be enabled in templates for that to work (see PHP in Templates).


{embed="shared/head"} - include the template head from the template group shared

<body class="{if segment_1 == ''}home{if:else}{segment_1}{/if}">

if the URI segment (EE/CI works with segments eg site.com/segment1/segment2/xxx) is empty (you are on the home page (www.site.com), then add no body class.

else, the user is on a page (in EE this is a template group), so set the class to be the name of the template group.

site.com/about-us produces class="about-us" - handy for page specific styling.

{embed="shared/masthead"} - include masthead

and so on.

The rest are conditionals to check if the variables have values, and outputs them

I presume you're using EE2.0, I'm not sure what {organizaton} is specifically, but that style:

{organization} {foo} {/organization}

in code igniter at least, is generally the equivalent of a foreach or looping through a recordset:

foreach($organizations as $organization) { // do something }


This is written in Expression Engine's own templating language.

You would have to check the documentation to see whether there is any way to debug variables.

Possibly helpful links:

  • Quick Reference Chart

  • PHP in Templates

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜