We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Undefined Index

Development and Programming

paulmichaelsmith's avatar
paulmichaelsmith
3 posts
15 years ago
paulmichaelsmith's avatar paulmichaelsmith

Hi,

I’m in the process of creating templates in EE (2.1) and I’m running into difficulty because I want to use some custom PHP within my EE templates.

I’m getting the following error:

A PHP Error was encountered
Severity: Notice
Message: Undefined index: grid
Filename: libraries/Functions.php(640) : eval()'d code
Line Number: 4

The code I’m trying to place within my EE templates is:

<?php
    $poster_classes = array ('lifted','helvetica','kcaco','eboy','haters');
    $show_grid = $_GET['grid'];
    require("./utils/css_browser_selector.php");
?>

I believe it’s related to using the $_GET (removing it doesn’t produce an error). I think its because grid is not on the querystring. Is that true?

Essentially I want to do something like:

User types in: http://airfront.co.uk/?grid=1

<?php
    if($show_grid == "1") {
        require_once("./utils/grid/grid.php");
    }
?>

That grid.php will just spit some mark-up on the page.

Any help much appreciated!

Cheers, - Paul.

Moved to Development and Programming by Moderator

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
15 years ago
Sue Crocker's avatar Sue Crocker

Welcome to the ExpressionEngine forums, Paul. Moving to the Development forum for additional community support.

       
Greg Aker's avatar
Greg Aker
6,022 posts
15 years ago
Greg Aker's avatar Greg Aker

Paul,

use $this->EE->input->get(‘grid’); It will evaluate to FALSE if it doesn’t exist.

Honestly, I wouldn’t use requires and addtional PHP in your templates. Build a plugin to move all the logic to.

-greg

       
paulmichaelsmith's avatar
paulmichaelsmith
3 posts
15 years ago
paulmichaelsmith's avatar paulmichaelsmith

How do I use $this->EE->input->get(‘grid’)?

So for example the value of grid equals the string “true”, how do I display that value on the page?

Thanks for your help.

       
Milsoft's avatar
Milsoft
27 posts
15 years ago
Milsoft's avatar Milsoft

Instead of using:

$show_grid = $_GET['grid'];

As Greg suggests, you should use:

$show_grid = $this->EE->input->get('grid');

You can just echo the variable if you want to display it in your template:

echo $show_grid;
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.