#1 2014-10-26 12:46:27

Kostas
Member
Registered: 2014-10-22
Posts: 3

PHP in Views - Bug or Documentation outdated

I believe a part of the documentation is outdated or there is a bug inside.

Whenever I try to use this code I get an error, and if I understood other posts on the forum correctly than this is expected. As the parser will only run once and the ion tags can never contain dynamic values. Please correct me if I'm wrong.

I pasted the following code in the foundation5 theme page_blog.php right after the '<ion:partial view="page_header" />' tag.

<?php
   
  // Get the title of the page
  $page_title = '<ion:page:get key="title" />';
 
?>
 
<ion:page:articles>
 
  <!-- For each article, we display the page title as prefix -->
  <?php
 
    echo '<ion:article:title prefix="'.$page_title.' : " />';
 
  ?>
 
</ion:page:articles>

Source: http://doc.ionizecms.com/en/build-the-w … p-to-views

Error message:

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in .../public_html/application/libraries/ftl/parser.php(327) : eval()'d code on line 162
Tag error : <ion: >

PHP error : syntax error, unexpected T_VARIABLE, expecting ',' or ';'
in expression :
file : .../public_html/application/libraries/ftl/parser.php(327) : eval()'d code

Did anyone manage to get this working? Or should this piece of information be removed from the documentation, as it seems to spread some confusion on the forums.

Last edited by Kostas (2014-10-26 12:47:19)

Offline

#2 2014-10-27 10:15:31

Kink
Ion Tester
From: France
Registered: 2010-06-04
Posts: 581

Re: PHP in Views - Bug or Documentation outdated

@Kostas

You 're right, i think this way not work.
But you can do this :

<ion:page:articles>
 
  <!-- For each article, we display the page title as prefix -->
  <ion:page:title> : <ion:article:title />
  
</ion:page:articles>

Webmaster / OUF!WEB

Offline

#3 2014-11-05 15:28:33

epescol
Member
Registered: 2012-05-27
Posts: 86

Re: PHP in Views - Bug or Documentation outdated

I get the same error with

if(!empty('<ion:lingue:value />')) {

and then I change the code to

if('<ion:lingue:value />' != '') {

Offline

#4 2014-11-05 15:42:38

Kink
Ion Tester
From: France
Registered: 2010-06-04
Posts: 581

Re: PHP in Views - Bug or Documentation outdated

Keep in mind that php is computed AFTER Ionize tags, so, you can only test values straightly, not with php methods.
http://doc.ionizecms.com/en/build-the-w … p-to-views

But, there are many options of ionize tags to call php methods. Check the doc smile


Webmaster / OUF!WEB

Offline

#5 2014-11-05 15:46:34

Kink
Ion Tester
From: France
Registered: 2010-06-04
Posts: 581

Re: PHP in Views - Bug or Documentation outdated

@epescol, in your case, perhaps this piece of code working ? (not tested)

<ion:lingue:value is_not="">
    // do something
</ion:lingue:value>

Webmaster / OUF!WEB

Offline

#6 2014-11-05 19:40:21

epescol
Member
Registered: 2012-05-27
Posts: 86

Re: PHP in Views - Bug or Documentation outdated

@Klink

yes ....

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations