7

If the project has relatively low needs in terms of site-wide data (read, If you don't need custom fields), then I tend to store these in global variables and snippets. When I need to store more advanced content, I personally use low variables. Pretty much a default now on medium or big EE builds. You can then use custom fields like Matrix, Wygwam, playa, ...


7

Take a look at your main index.php file, you should see this line: // $assign_to_config['global_vars'] = array(); // This array must be associative Once that's uncommented and populated the variables should be available in your templates. For example: $assign_to_config['global_vars'] = array('analytics_key' => 'UA-XXXXXXX-XX'); That should be ...


5

The count variable is 1-indexed so you need to do {if count == 1}{/if} to get the first in a loop.


4

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


4

The variable {ip_address} is one of the standard global variables that is parsed last, even after advanced conditionals. That means you can't use it in a conditional. You can use Mo’ Variables (or Low Variables if you’re already using it) to have {logged_in_ip_address} available as an early parsed var, so you can use it in conditionals.


4

So both of the above should done done relatively easy with the query tool... The SQL you'll need is : SELECT count(*) as active_members from exp_members WHERE FROM_UNIXTIME(last_visit) > DATE_SUB(NOW(), INTERVAL 30 DAY); The second one would just be : SELECT count(*) as active_members from exp_members where group_id=1 OR group_id=3 OR group_id=5; You'...


4

I think UltraBob is right in that if you need a global variable available inside the module you need parse them inside the add-on. parse_globals() looks to be the way to do so (thanks to this answer on Stack Overflow). The following will show that the parsed global is available in the module: $parameter = $this->EE->TMPL->fetch_param('...


4

The issue is parse order. Read the attached pdf.parse order. Turn on the debugger and then view the template in your browser. Scroll down thru the debugger until you find the tag containing {current_url}. You will see that that {current_url} has not been parsed. According to the attached doc, it is not parsed until step 9 - last. In your module, try $...


3

Global variables declared in Design > Templates > Global Variables cannot contain EE tags, PHP, or other variables inside them. User-defined global variables are not run through the template engine, so you cannot place EE Tags, PHP, or variables inside them. If you need to place EE tags inside re-usable bits of code then you'll need to use Snippets: ...


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

Why not use http://eeinsider.com/articles/multi-server-setup-for-ee-2/ as a basis and work from there?


2

As EE parses {ip_address} after advanced conditionals it easy enough to get that data parsed sooner. I haven't got Low Variables installed on this site otherwise I would use it. Instead you could add it as a variable to config.php: $config['ipaddress'] = $_SERVER['REMOTE_ADDR']; Or I've actually added to my bootstrap file but it achieves the same thing.


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

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 ...


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.


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

This will not work as object isn't being initialized. You can use PHP $_COOKIE to get it. $assign_to_config['global_vars']['user_location'] = $_COOKIE['user_location'];


1

This standard global variable should work with logged in member. See here http://ellislab.com/expressionengine/user-guide/templates/globals/single_variables.html#ip-address


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