4

Using the matches operator, which was added in EE v2.9.0: {if segment_2 ~ "/^\d+$/"} [...] {/if}


3

The issue is one of parsing order... User Defined global variables are the last thing to be parsed. This PDF outlines ExpressionEngine’s Parse Order. This page in the docs details the Rendering Stages of the EE template engine. The solution is to switch to using a Snippet instead.


2

There are a number of approaches you could take. Here's one using native EE functionality We can see from the Twitter docs that we need the following markup: <meta name="twitter:card" content="summary"> <meta name="twitter:site" content="@nytimes"> <meta name="twitter:creator" content="@SarahMaslinNir"> <meta name="twitter:title" ...


2

One really simple way to get around parse order is just to use an embed. {embed="embeds/_rest" ip_address="{ip_address}"} Then in your embedded template (embeds/_rest): {exp:rest url="http://domain.com/{embed:ip_address}" verb="get" format="json"} {/exp:rest} Embeds get a bad rap performance-wise, but as long as you aren't using them excessively or ...


2

Create a plugin - don't do this in the template. Then you can do whatever you like in pure PHP (with access to all of EE's helper functions, libraries, etc), create a variables array, and then return it for use as template tags.


2

First of all, the stylesheet tag needs quotation marks. {stylesheet="global_embeds/style"} If you link to the JS file using path variable, all the templates variables on the linked file will be parsed. {path="global_embeds/init.js"} But I really don't think it's good for performance. It's much better to use static links for the JS and CSS.


2

Well the short answer is you can'tshouldn't easily, it raises all sorts of questions regarding the security model! However there may be alternatives. You could for instance write an extension for EE that exposes an ACTion (as Derek said), or more simply just write a template, and then get your information through AJAX/curl from your other external page. ...


2

You're running into a parse order issue here. The conditionals are parsed before the global variables, and therefore your comparison is taking place with the actual value you have within the conditional instead of the parsed value. There are a couple things you can do. 1) Use a snippet instead of a global variable, as these parse much earlier 2) Use an ...


1

Well, you can use flashdata to achieve your requirement. For this please follow below syntax. To set the Flashdata:- ee()->session->set_flashdata('your_key', 'your_value'); To get the Flashdata:- echo ee()->session->flashdata('your_key'); HTH


1

If you are planning to develop a 'generic' block of template code and then reuse it multiple times within your site, you necessarily need a mechanism for specifying what data you want to display through the template. As you point out, a common way to provide this data to a template is via the channel:entries tag pair. If I understand your question ...


1

I think you are mixing up versions of EE. {template_group} is not a standard global variable in EE2, so not a surprise that it doesn't work. For a full list of Global Variables that work in EE2 see here: https://docs.expressionengine.com/v2/templates/globals/single_variables.html HT


1

Low Variables extends the native Template Variables, so for every LV, there is a TV. Just leave 'em and if you need to delete them, do so via LV.


1

When using EE variables inside of javascript, it's always best to separate the variables out onto separate lines to prevent the template parser from treating them as javascript objects (and thus skipping them). {if logged_in_group_id == "5"} <script>dataLayer = [{ 'userID': '{logged_in_username}' }];</script> Rest of the ...


1

That's normal behaviour but can be a little confusing the first time you encounter it. You need to use {logged_in_username}, {logged_in_member_id}, and {logged_in_screen_name}. In order to be able to use some member variables inside tags that already parse their own member information, such as the channel entries tag, it is necessary to use an ...


1

http://gotolow.com/addons/low-variables may be your answer, that will all you mention plus a whole lot more.


1

This looks like a bug, to me. Probably something related to different PHP between the environments. Starting with version 2.9, EECMS changes the way conditionals are evaluated. So this bug is probably gone. Conditionals should always use the syntax: {if current_path == "/"} ... {/if} But {current_path} is parsed at the end of parsing stages. This ...


1

Your best bet is to hold this URL via a global variable defined inside of your config file (as standard user-defined global variables will be scoped to each site). Or to get fancier, use Low Variables, which will may help you elsewhere in your site build as well.


1

The answers here didn't work for me, but a simple query does. Just in case this helps soneone else... $sql = "select variable_data from exp_global_variables where variable_name = '$glob_var' "; $results = $this->EE->db->query($sql); $row = $results->first_row(); //returns an object $global_var_value = $row->variable_data; //get result from ...


Only top voted, non community-wiki answers of a minimum length are eligible