Field level Textile doesn’t work in PHP in template
Posted: 13 July 2004 05:04 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  103
Joined  06-03-2003

Here’s the setup:

Template set to parse PHP on Output.

Field {extended} set to Textile on submit/update form in CP.

Code in page:

<?php
    $my_var
= "{my_custom_field}";
    if (
$my_var == "foo") {
?>

{extended}

<?php } ?>

This will output “{extended}” (without the quotes of course.)

But set the formatting on the field to “none” and then change the code to the following and it works as it should:

<?php
    $my_var
= "{my_custom_field}";
    if (
$my_var == "foo") {
?>

{exp
:textile}{extended}{/exp:textile}

<?php } ?>

This is a simplified version of what we are trying to do but it demonstrates the problem. I only tried field formatting of ‘none’ and ‘textile’  so far.

 Signature 

Shane Robinson - twitter.com/shane

PodCamp Hawaii, October 24-25, 2008 - http://2008.PodCampHawaii.com
http://www.barefeetstudios.com
http://www.beachwalks.tv
http://reef.beachwalks.tv

Profile
 
 
Posted: 14 July 2004 05:49 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

If you don’t use the surrounding PHP do you get the correct content from the “extended” field or do you still get the actual field name appearing?

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 14 July 2004 11:59 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  103
Joined  06-03-2003

Hi Chris,

With no PHP, the extended field content is returned however it’s marked-up to be returned at the field level. Just did some more tests and here is an interesting result. Here is the acutal code block I’m dealing with. The {cf_include_extended} is a custom pulldown field that contains values: No, Top, Bottom, Both. We are using the {cf_extended} field for additional notes, links to additional and related resources, and links to audio files. For very long articles, we give the client the ability to place the extended material at the top or bottom of the page, or both, based on the value they choose in the pulldown.

The following displays {cf_extended} if the cf_extended field is set to Textile or xhtml. It displays its content if set to none.

<?php $inc_ext = '{cf_include_extended}'; ?>

    
<h2>{title}</h2>

<?php  if(($inc_ext == "Top") || ($inc_ext == "Both")) { ?>
        {cf_extended}
<?php } ?>
        {cf_summary}
        {cf_body}
<?php  
if(($inc_ext == "Bottom") || ($inc_ext == "Both")) { ?>
        {cf_extended}
<?php } ?>

Here’s the interesting part. The following slight variation of the above works if the cf_extended field is set to Textile. The Textile plugin tags were added to the bottom conditional. But of course the content at the bottom is spaced wider apart due to the “doubling” of the Textile formatting (one on the field directly and the one in the template.)

<?php $inc_ext = '{cf_include_extended}'; ?>

    
<h2>{title}</h2>

<?php  if(($inc_ext == "Top") || ($inc_ext == "Both")) { ?>
        {cf_extended}
<?php } ?>
        {cf_summary}
        {cf_body}
<?php  
if(($inc_ext == "Bottom") || ($inc_ext == "Both")) { ?>
        {exp
:textile}{cf_extended}{/exp:textile}
<?php } ?>

The ability to individually format a given field is brilliant so we want to keep as much formatting and plugins out of the templates as possible.

Thanks for your help on this. Please LMK if there are any other details that could help.

 Signature 

Shane Robinson - twitter.com/shane

PodCamp Hawaii, October 24-25, 2008 - http://2008.PodCampHawaii.com
http://www.barefeetstudios.com
http://www.beachwalks.tv
http://reef.beachwalks.tv

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64978 Total Logged-in Users: 24
Total Topics: 82016 Total Anonymous Users: 20
Total Replies: 440814 Total Guests: 194
Total Posts: 522830    
Members ( View Memberlist )