Sonu2007 Posted October 1, 2017 Share Posted October 1, 2017 There is way so i can use smarty tags inside structural data syntax? something like <script type="application/ld+json"> { "@context" : "http://schema.org", "@type" : "Organization", "name":"{$title}", "description": "{$desc}", Above code return output as following instead of actual site title and description "name":"{$title}" "description": "{$desc}" 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 1, 2017 Share Posted October 1, 2017 use {$pagetitle} instead of {$title} 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted October 2, 2017 Author Share Posted October 2, 2017 still same, its show syntax as it is instead of output 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 2, 2017 Share Posted October 2, 2017 if possible show me the full code then? 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted October 2, 2017 WHMCS Developer Share Posted October 2, 2017 The issue here is smarty's intelligent recognition that you are running javascript. Try replacing your { in the first line with {$ldelim} - see https://www.smarty.net/docs/en/language.function.ldelim.tpl#idp36077424 for the full Smarty documentation <script type="application/ld+json"> {$ldelim} "@context" : "http://schema.org", "@type" : "Organization", "name":"{$title}", "description": "{$desc}", .... {$rdelim} 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted October 2, 2017 Author Share Posted October 2, 2017 (edited) Non of them are working, my following code print as it is {literal} <script type="application/ld+json">{$ldelim} { "@context": "http://schema.org", "@type": "Organization", "name": "{$pagetitle}", "description": "{$desc}", } {$rdelim} </script> {/literal} Edited October 2, 2017 by Prahost 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 2, 2017 Share Posted October 2, 2017 10 minutes ago, Prahost said: Non of them are working, my following code print as it is {literal} <script type="application/ld+json">{$ldelim} { "@context": "http://schema.org", "@type": "Organization", "name": "{$pagetitle}", "description": "{$desc}", } {$rdelim} </script> {/literal} try this: <script type="application/ld+json"> {ldelim} "@context": "http://schema.org", "@type": "Organization", "name": "{$pagetitle}", "description": "{$desc}", {rdelim} </script> 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 2, 2017 Share Posted October 2, 2017 2 hours ago, WHMCS Andrew said: The issue here is smarty's intelligent recognition that you are running javascript. Try replacing your { in the first line with {$ldelim} - see https://www.smarty.net/docs/en/language.function.ldelim.tpl#idp36077424 for the full Smarty documentation <script type="application/ld+json"> {$ldelim} "@context" : "http://schema.org", "@type" : "Organization", "name":"{$title}", "description": "{$desc}", .... {$rdelim} it's {ldelim} and {rdelim} 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted October 2, 2017 Author Share Posted October 2, 2017 following code working fine If i remove {literal}. As per my understanding all java scripts need to be in {literal} tag correct..? there is any way to use smarty without {ldelim) ? <script type="application/ld+json"> {ldelim} "@context": "http://schema.org", "@type": "Organization", "name": "{$pagetitle}", "description": "{$desc}", {rdelim} </script> 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 2, 2017 Share Posted October 2, 2017 Just now, Prahost said: following code working fine If i remove {literal}. As per my understanding all java scripts need to be in {literal} tag correct..? there is any way to use smarty without {ldelim) ? <script type="application/ld+json"> {ldelim} "@context": "http://schema.org", "@type": "Organization", "name": "{$pagetitle}", "description": "{$desc}", {rdelim} </script> when you use {literal} it will ignore all the code in between, so {$pagetitle} will be displayed as it and will not be replaced with it's value. on the other hand {ldelim} and {rdelim} work the same as {literal} but gives you the option to put some variables that you need to include in your CSS/JS codes, below is how this can be done using {literal} {literal} <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "Organization", "name": "{/literal}{$pagetitle}{literal}", "description": "{/literal}{$desc}{literal}", } </script> {/literal} 0 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted October 2, 2017 Author Share Posted October 2, 2017 1 minute ago, sentq said: when you use {literal} it will ignore all the code in between, so {$pagetitle} will be displayed as it and will not be replaced with it's value. on the other hand {ldelim} and {rdelim} work the same as {literal} but gives you the option to put some variables that you need to include in your CSS/JS codes, below is how this can be done using {literal} {literal} <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "Organization", "name": "{/literal}{$pagetitle}{literal}", "description": "{/literal}{$desc}{literal}", } </script> {/literal} So there is no difference / affect on code, we can use either? 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted October 2, 2017 WHMCS Developer Share Posted October 2, 2017 11 minutes ago, sentq said: it's {ldelim} and {rdelim} It is indeed. 2 minutes ago, Prahost said: So there is no difference / affect on code, we can use either? Exactly. Although, in theory, you shouldn't actually need any literal tags at all as with Smarty V3, smarty will intelligently recognise the javascript part. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 2, 2017 Share Posted October 2, 2017 @WHMCS Andrew true, but the following will give you error: <script> function(){ // Your code } </script> you need to add space between function() and { 1 Quote Link to comment Share on other sites More sharing options...
Sonu2007 Posted October 2, 2017 Author Share Posted October 2, 2017 Thank you all. Everything is sorted now. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.