So I’ve been hired by a client to upgrade their site from EE 1.x to 2.x.
As part of the upgrade, I’ve got to fix some legacy code in the templates. This works just fine in EE 1.x but I don’t really know how to approximate it in EE 2.x
<?PHP
global $IN;
$parameters = "";
foreach ($_GET as $key => $value) { $key = $IN->clean_input_data($value); }
if ($category = $IN->GBL('category', 'GET')) { $parameters = $parameters . " category=\"" . $category . "\""; }
if ($author = $IN->GBL('author', 'GET')) { $parameters = $parameters . " author_id=\"" . $author . "\""; }
if ($search = $IN->GBL('search', 'GET')) { $parameters = $parameters . " search:text=\"" . $search . "\" search:title=\"" . $search . "\""; }
if (is_numeric($IN->fetch_uri_segment('2')) && is_numeric($IN->fetch_uri_segment('3'))) {
$url_title = " url_title=\"{segment_4}\"";
}
?>I first tried to solve it in the most straightforward way I could think of:
<?php
/* This is gnarly. Needs to be replaced ASAP
Basically all that it does is build a parameter list for the channel display tag */
$thisone =& get_instance();
$parameters = '';
if ($category = $thisone->input->get('category', TRUE)) {$parameters .= ' category="' . $category . '"';}
if ($author = $thisone->input->get('author', TRUE)) {$parameters .= ' author_id="' . $author . '"';}
if ($search = $thisone->input->get('search', TRUE)) {$parameters .= ' search:text="' . $search . '" search:title="' . $search . '"';}
?>I have also tried all sorts of variations on the above code:
$this->EE =& get_instance();
...$thisone->EE->input->get…I’ve also tried omitting the call to get_instance() and then attempting to access the global object as though it has been set already:
...$this->EE->input->get…Or treating the current $this object as the get_instance() value:
...$this->input->get…etc.
So now, I’m thinking that I should either try to accomplish the same things that this code is doing by CREATING a plugin that returns the data I want. Other than that I have no ideas. The problem with this idea for me is that the variables $search, $category, $author are occasionally used in other <?php ?> snippets throughout the templates, especially as part of the test in conditionals.
Any advice on how to move forward with this would be much appreciated.