Print smarty var in link file param - smarty

One simple thing:
I want to combine the {s name="*"} and {link file="*"} blocks.
src="{link file='{s name='sFooterPaymentsIcon'}{/s}'}"
The problems should be the
'
signs.
How can I do that?

You can try assign a new variable and pass that on file parameter, like:
{assign var="my_file" value="{s name='sFooterPaymentsIcon'}{/s}"}
and then
src="{link file="$my_file"}"

You can do it this way:
//Assign snippet value to variable $snippetLink, in case variable is empty - assign LinkInCaseSnippetEmpty
{assign var='snippetLink' value='LinkInCaseSnippetEmpty'|snippet:'TheNameOfSnippet':"Namespace/If/Need"}
//assign source from variable $snippetLink
src="{link file=$my_file}"
In one line:
src="{link file='LinkInCaseSnippetEmpty'|snippet:'TheNameOfSnippet':'Namespace/If/Need'}"

{s} is for for text-snippets and should not be used for configuration-variables. If you need to make an include configurable, you should create a plugin for that.
The plugin should have a frontend-subscriber and make the file-include configurable via backend configuration-form. In the subscriber you can pass the configuration-value for the file-include to the frontend-view.

Related

Same URL for different rutes expression in codeigniter

How use same url for different rutes expression in codeigniter.
For exemple, to use "x" like any word in my code and always to result in same url?
$route['list'] ='x/list';
Url expected: mysite.com/list
You have to set a value for x as $x = "http://www.example.com"; then use it like this $route['list'] ='$x/list'; but you may need to revise the $route[''] variable name list, view example on https://www.javatpoint.com/codeigniter-url-routing

Remove part of file path in Ruby

I am are receiving an array as a variable
Is an example
["/a/b/01_Sources/02_Transferred/06_CPAS/Redbull/from_MediaHouse/Transcripts/MI201711200143.xlsx", "/a/b/01_Sources/02_Transferred/06_CPAS/Redbull/from_MediaHouse/Transcripts/MI201703030110.pdf"]
The following statement creates this list:
<%= var(file_list_array).map{|file| "<li>#{File.basename(file)}</li>"}.join("\n")%>
MI201711200143.xlsx
MI201703030110.pdf
The following statement creates this list
<%= var(file_list_array).map{|file| "<li>#{file}</li>"}.join("\n")%>
/a/b/01_Sources/02_Transferred/06_CPAS/Redbull/from_MediaHouse/Transcripts/MI201711200143.xlsx
/a/b/01_Sources/02_Transferred/06_CPAS/Redbull/from_MediaHouse/Transcripts/MI201703030110.pdf
But what I would really like:
/Redbull/from_MediaHouse/Transcripts/MI201711200143.xlsx
/Redbull/from_MediaHouse/Transcripts/MI201703030110.pdf
What do I need to change to get that ?
Assuming you have your array of file paths in an array you could do.
file_paths.map{|path| path.gsub(/.*(\/Redbull\/.*)/, $1) }
This will replace each item with whatever is below the "Redbull" directory
Alternatively if you didn't want to preprocess that list you could just put it in your display code, but that will make it less clear as to what you need to send the displaying logic.
<%= var(file_list_array).map{|file| "<li>#{file.gsub(/.*(\/Redbull\/.*)/, $1)}</li>"}.join("\n")%>
Try this
file_list_array[0].split("06_CPAS")[1]
assuming you want to split from "06_CPAS" . You can pass it as a variable too like this
split_str = "06_CPAS"
index = 0
file_list_array[index].split(split_str)[1]

Add parameters to URLs in ezPublish

I have an url like $article.url|ezurl(,'full'), but I need to pass additional parameters to it (eg. (offset)/2).
Please note that I am using attribute_view_gui for images, so I can't just hardcode it.
I tried creating variables:
{def $url = $article.url|ezurl(,'full')}
And then adding values there, but it's useless.
What can I do?
You can add view parameters to the URL before passing it to the ezurl() template operator.
<a href={concat( $article.url, '/(offset)/2' )|ezurl}>{$article.name|wash}</a>
Note that ezurl adds double quotes by default so you don't need to add them in your html/tpl code with <a href="{concat...}">...
If you want to use a $url variable, then you need to tell ezurl not to add these quotes :
{def $url = concat( $article.url, '/(offset)/2' )|ezurl('no')
$name = $article.name}
{$name|wash}
You can also use the "owviewparams" extension to modify, add or remove view parameters from an url : http://projects.ez.no/owviewparams

Printing this variable in smarty

I'm having an array $customPre. I want to print the element of the array "Please specify which fund". I am doing like this:
{$customPre.Please specify which fund}
But it's not working.
In this case you need to use PHP-like syntax that is similar to PHP: {$variable['key']}.
If In PHP you have:
$smarty->assign('customPre', array ('Please specify which fund' => 'This is value'));
In Smarty you need to use:
{$customPre['Please specify which fund']}
And the output for this will be:
This is value
I believe you cannot use in this case dot syntax ( {$customPre.Please specify which fund}) because it's probably looks for whitespaces in keys. Even adding quotes won't help.

Freemarker: assign interpreted variable to other variable

I would like to assign the result of an interpreted variable to another varialbe.
Freemarker provides the built-in ?interpret to interpret a variable holding an ftl expression. See http://freemarker.sourceforge.net/docs/ref_builtins_expert.html#ref_builtin_interpret
If I do
[#if var1?has_content && var1?starts_with(r"${")]
[#assign interpretedValue = var1?interpret!""]
[#interpretedValue/]
[/#if]
The [#interpretedValue/] will output the interpreted value.
However, I'd like to assign the value of the interpreted value to a variable (in order to do some things such as ?has_content in the rest of my code). I tried [#assign varInterpretedValue = #interpretedValue] but this does not work.
Is this possible?
Yes, like this:
[#assign capturedOutput][#(var1!'')?interpret /][/#assign]
${capturedOutput} [#-- Attention! Put this into #noescape if you are inside #escape! --]
Note that the !'' suff has to before the ?interpret, otherwise it doesn't do anything (since the result of ?interpret is always non-null).

Resources