evolution.x Posted January 31, 2013 Share Posted January 31, 2013 Hi, Is it possible to use smarty variables in the product description? I need to add: {if $cookie->isLogged()} <p>logged in</p> {else} <p>not logged in</p> {/if} Any workaround to get these working in the description? At the moment it just displays the code and does not run it? Cheers Link to comment Share on other sites More sharing options...
vekia Posted January 31, 2013 Share Posted January 31, 2013 nope, you can't use smarty variables in descriptions. You can only edit template files to get smarty variables values Link to comment Share on other sites More sharing options...
evolution.x Posted January 31, 2013 Author Share Posted January 31, 2013 Hi, Thanks for your reply, is there any other way that i could hide parts of the description until the user logs in? Link to comment Share on other sites More sharing options...
vekia Posted January 31, 2013 Share Posted January 31, 2013 well in my opinion: YES. but it isn't as simple as it seems. you can create a block with class like .onlyforlogged in description (by using HTML in wysiwyg editor), for example: <div class="onlyforlogged">HIDDEN CONTENT HEREE</div> next, add into product.tpl template file code like below: {if !$cookie->isLogged()} {literal} <script> $(".onlyforlogged").remove(); </script> {/literal} {/if} Link to comment Share on other sites More sharing options...
evolution.x Posted January 31, 2013 Author Share Posted January 31, 2013 Thanks for that, i will give it a try. This way you will still see the hidden content if you view the source code of the page, true? Cheers Link to comment Share on other sites More sharing options...
vekia Posted January 31, 2013 Share Posted January 31, 2013 nope, code: <script> $(".onlyforlogged").remove(); </script> is for delete div .onlyforlogged, not to hide it Link to comment Share on other sites More sharing options...
evolution.x Posted January 31, 2013 Author Share Posted January 31, 2013 Thanks, i'll try this and let you know. Once again thanks for your input! Link to comment Share on other sites More sharing options...
vekia Posted January 31, 2013 Share Posted January 31, 2013 sure, im waiting for your response about solution. I will also try it on my own test shop Link to comment Share on other sites More sharing options...
evolution.x Posted January 31, 2013 Author Share Posted January 31, 2013 Would it be possible to remove and replace? $(".onlyforlogged").remove(); $('.onlyforlogged').html('Login to view'); Link to comment Share on other sites More sharing options...
evolution.x Posted January 31, 2013 Author Share Posted January 31, 2013 (edited) i have tried the code you provided, it does hide the content but if you view the source code of the page the content is still there? Edited January 31, 2013 by evolution.x (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted January 31, 2013 Share Posted January 31, 2013 well i checked this code on my own test shop and you've got right - the code still appears in source. So maybe the best way is to change content, exactly as you said. try to add: {if !$cookie->isLogged()} {literal} <script> $(".onlyforlogged").html('log in first'); </script> {/literal} {/if} EDIT it works the same as first code Link to comment Share on other sites More sharing options...
evolution.x Posted January 31, 2013 Author Share Posted January 31, 2013 Both codes work the same but they only remove / replace the content from the DOM not the actual source Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now