We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Store template-tag value as a php-variable

Development and Programming

gonzales's avatar
gonzales
4 posts
14 years ago
gonzales's avatar gonzales

Hi,

I’m trying to store the value of a template-tag into a php-variable but is this even possible?

I want the user to enter a flickr-url(ex.:http://www.flickr.com/photos/trackgent/sets/72157627336324121/) in this field and I want to extract the set-id from it using php, but mayby there is another way?

This is my code for the moment, just trying to get the right value:

{exp:channel:entries  channel="kunstenaars" status="open"}
    {exp:ce_img:pair src="{artist_header_img}" width="355" height="202"}
    {made}
    {/exp:ce_img:pair}
    <h2>{title}</h2>
    {artist_txt_{country_code}}
    
    <?php 
        $art_gallery_url = "{art_gallery}";
    ?>
{/exp:channel:entries}
<section id="art-gallery">
    <?php 
        echo $art_gallery_url;
    ?>

    <ul>
    {exp:eehive_flickr:photoset set_id="72157627336324121" size="medium"}
        <li {if count == 1}class="active"{/if}>
            <a href="#">_                {flickr_url_medium}_            </a>
        </li>
    {/exp:eehive_flickr:photoset}
    </ul>
    <div class="controls">
        <a href="#" class="next">></a>
        <a href="#" class="prev"><</a>
        <a href="#" class="close">x</a>
    </div>
</section>

If I put the parsing-stage setting to output, I get a php error: Parse error: syntax error, unexpected T_STRING in /opt/www/gonzales/web/www.track.be/system/expressionengine/libraries/Functions.php(656) : eval()’d code on line 15

If I use the input stage I get the template tag {art_gallery} when echooing my variable with php.

       
Fusion Design's avatar
Fusion Design
128 posts
14 years ago
Fusion Design's avatar Fusion Design

Hi there,

Are you calling in more than 1 entry from your kunstenaars channel? If so then your probably trying to echo an array, in which case the following would be better

<?php print_r($art_gallery_url); ?>

If however you’re only calling 1 entry form your kunstenaars channel, you shouldn’t need to have php and can use the following

{exp:channel:entries  channel="kunstenaars" status="open" limit="1"}
    {exp:ce_img:pair src="{artist_header_img}" width="355" height="202"}
    {made}
    {/exp:ce_img:pair}
    <h2>{title}</h2>
    {artist_txt_{country_code}}
    
<section id="art-gallery">
    {art_gallery}
{/exp:channel:entries}

    <ul>
    {exp:eehive_flickr:photoset set_id="72157627336324121" size="medium"}
        <li {if count == 1}class="active"{/if}>
            <a href="#">_                {flickr_url_medium}_            </a>
        </li>
    {/exp:eehive_flickr:photoset}
    </ul>
    <div class="controls">
        <a href="#" class="next">></a>
        <a href="#" class="prev"><</a>
        <a href="#" class="close">x</a>
    </div>
</section>
       
Lisa Wess's avatar
Lisa Wess
20,502 posts
14 years ago
Lisa Wess's avatar Lisa Wess

Thanks for helping out, FD! gonzales - those look like good options. Depending on what you’re doing, it may be better to look at something like the String Plugin and avoid needing PHP in your template at all.

And of course, welcome to our community =) II’ve also moved this down to Dev & Programming for you.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.