Using a variable in $smarty.get? - smarty

I need to retrieve the $_GET data from the URL in a smarty .tpl file. The specific $_GET I need to retrieve is in a loop. I need to use the example below but with a variable for page.
{* display value of page from URL ($_GET) http://www.example.com/index.php?page=foo *}
{$smarty.get.page}

This should work:
{assign var="foo" value="assign whatever you want"}
{$smarty.get.$foo}

Related

Pass $_GET variable through ajax call's php file

I have an jQuery AJAX call that lists records from database based on $_GET variable called "website_identificator". Imagine the main file is called "index.php" (where the AJAX call is presented) and the PHP script file that is called by the AJAX is called "phpscript.php". Now also imagine that I'm using the $_GET "website_identificator" to decide what to show on this page, but this $_GET "website_identificator" is beneficial for the PHP script file so it can filter the records and show the right ones. How to I use this $_GET variable in "phpscript.php", because when I try to use it like this:
<?php $getVar = $_GET['website_identificator']; ?>
PHP understands it like "phpscript.php?website_identificator=STRING" but not "index.php?website_identificator=STRING" despite the fact that I called the file through AJAX call.
I understand that you call index.php with the query parameter website_identificator? You have to include that value in the AJAX request and pass it on to phpscript.php. There is no magical way to retrieve the query parameters from another script, both are standalone.

Request::is() with variable

I have route like this
Route::get('/edit_faq/{id}', 'Admin\DashboardController#add_faq');
with prefix
admin
and i want to use Request::is() but didn't find any thing to use with variable .
also i am using this in blade file like this
if("{{Request::is('admin/faq')}}"){}
is there any way to check this in blade like we do in route file just by declaring variable {id}
thanks in advance
You have to provide arguments to it.
#if(Request::is('admin/faq', 'admin/edit_faq/*'))
Then it will match with any of the given arguments. Hope you are looking for this only.
I had a situation like yours where I wanted to add a variable to Request::is() for a list with a foreach loop in a laravel blade template.
class="{{ Request::is('*items/edit/'.$item->id) ? 'active' : '' }}"
Add variable outside ' ' and it will work.
correct way to use in blade file is like this:
#if(Request::is('admin/faq'))
...
#endif
in controller :
if ($request->is('admin/*')) {
//
}
The is method allows you to verify that the incoming request path
matches a given pattern. You may use the * character as a wildcard
when utilizing this method:

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.

Spring JSP variable not assigned

I have in my JSP page code like this:
<spring:url value="" var="url"/>
EN
And issue is that parameter url in link is always set to empty String.I would expect that if I type url like localhost:8080/test the url variable will hold this value and it will be replaced in link so it would look like /change_locale?locale=EN&current=test. However it is always generated like /change_locale?locale=EN&current=.What I am doing wrong? Best regards
In
<spring:url value="" var="url"/>
Your value value is the empty String. Because of this, the URL is relative.
Spring uses UrlTag to construct the value from a <url> tag. You'll want to take a look at its createUrl method in the source code if you're curious.
In this case, it will generate a value that is the empty String and store it in a page scope attribute named url. That's what you get when rendering
${url}

pyrocms files plugin variables

I want to pull a url segment variable into the pyrocms file plugin call. it would look like
{{files:listing folder="[segment(2)]"}}
or something of the sort. What is the trick for embedding
{{url:segments..}}
inside
{{files:listing folder="…}}
I am trying to setup this up for a conditional query for a photo gallery
If you take a look at the PyroCMS Tags documentation you will see this clearly documented in the "Tag Attributes" section.
You may also use the output from other tags as attribute values in your tags. For example if you wanted the url segment to default to the slug of the currently viewed page you could do this:
{{ url:segments segment="1" default=page:slug }}
Here is an example showing the proper use of quotes and braces when the tag used as the attribute value has an attribute itself.
{{ url:segments segment="1" default={foo:bar value="baz"} }}
Tip: Omit quotes and braces when using tags as attribute values. The only exception is when the tag you are using as the attribute value has its own attributes.
So you can do that easily with:
{{ files:listing folder={url:segments segment="2"} }}
Basically you don't need to pretend it's a string if it's not. You can just send the foo:bar arguments through, but it if has attributes you can "group" the attributes with the call via a single { and }.
Simple right? :)

Resources