smarty v3, get value from smarty - smarty

how get variable from smarty v3?
With Smarty v2 i use this function: get_template_vars, but in v3 this no't work.

They removed the underscores and went camelCase in version 3: getTemplateVars()

Related

Use a variable inside a variable in Smarty 2 template

I am trying to use a smarty variable inside a smarty variable in a template.
The following will work in smarty 3 but not in smarty 2:
{$_content_{$id}.content_title}
to display for example:
{$_content_10.content_title}
In smarty 2 it only throws an error. Is there any way to do this in smarty 2?

How to make url from a string in Laravel?

Does a Laravel has an included function to convert a string to an url? Or should I use some standart PHP libraries? But with standard library there is a problem with duplicating url... So there should be a script for every model..?
Example:
'Apple Cake'=>'apple-cake'
If you’re wanting to convert a title-case word to a URL-friendly string, then you can use the Str::slug() method:
use Illuminate\Support\Str;
$slug = Str::slug('Apple Cake'); // apple-cake
I also have found https://github.com/cviebrock/eloquent-sluggable slug maker for Laravel, if someone will have the same problem

Smarty check if URL contains some value

I use smarty and I want to check if my currenty URL contains some value.
Therefore I use the following code, but that does not work.
{if $smarty.server.HTTP_REFERER|strstr:'domain=transfer&sld='}
The full URL;
https://example.com/cart.php?a=add&domain=transfer&sld=value&tld=.com
What am I missing?
Try REQUEST_URI instead of HTTP_REFERER.
This will do it.

Using #lang directive als default value of #yield directive in Blade/Laravel

Regarding the Laravel documentation, the #yield directive in a blade template can have a default value as second argument. Since I'm developing a multi language site, how is it possible to use the #lang directive as default value?
I've already tried:
#yield('title', #lang('title'))
#yield('title', lang('title'))
neither of them is working.
Use Lang::get() or trans() to get the localized version of your string:
#yield('title', trans('title'))

Laravel 4.1 Blade + Handlerbar escaping issue (%20, %7B etc ..)

I'm working with Laravel 4.1 (recently update to) and Handlebars.
I have a view where I mix Blade template and Handlebars template.
My problem is that this line:
View
return me this :
http://local/event/%7B%7Bid%7D%7D
instate of :
http://local/event/7 (if id = 7)
Note that this line return the correct value :
<span>#{{id}}</span>
The issue occurs only in the url() Laravel helper :(
Thank you in advance!
You cant get Handlebars to put the $id there - because it is a Laravel PHP function url() that must resolve first, and the result is passed to Handlebars.
i.e. this would work:
View
But you cant get Handlebars to use an ID in the Laravel function.
What you are trying to do in your example is get Laravel to pass a URL to Handlebars, Handlebars inserts the ID, then Laravel finishes the function - which wont work.
In my case the workaround is
View

Resources