|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
bestedge Smarty n00b
Joined: 17 Nov 2016 Posts: 1
|
Posted: Thu Nov 17, 2016 1:28 pm Post subject: Need to add some code |
|
|
My situation is that I have a plugin for WordPress and all of the templates for the pages are written in smarty.
I have a code block:
<tpl ifset="collection.salesbutton">
<div class="collection-payment-buttons">
{collection.salesbutton}
</div>
<div class="collection-payment-paypal-buy-now">
</div>
</tpl ifset="collection.salesbutton">
And what I really want to do is add a line of PHP to it, but the {php} doesn't work and has apparently been removed.
<tpl ifset="collection.salesbutton">
<div class="collection-payment-buttons">
{collection.salesbutton}
</div>
<div class="collection-payment-paypal-buy-now">
<?php the_field('cd_paypal_code'); ?>
</div>
</tpl ifset="collection.salesbutton">
But obviously, I can't just add <?php the_field('cd_paypal_code'); ?> -- because that doesn't work. So I just need to know how to make that happen in this tpl thing.
Yes, I already tried googling a lot to figure it out, and the documentation all starts from you have no files, not how to add something to a big existing thing. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Nov 17, 2016 10:53 pm Post subject: |
|
|
The best way to do it is to not do it.
Write a template function for Smarty and use it as you would any other Smarty template tag.
Or, if that's a static piece of code, make a subtemplate and include it in there. Even if not static… Refer to {include} documentation for details. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|