mickeyboy1 Posted July 28, 2015 Share Posted July 28, 2015 I am using 1.6.0.14 and currently have something like this in a .tpl file {assign var=catsort value=[100,101,102,103,104,105,106,107]} {assign var=catsort1 value=[162,163,164,165,166,167,168,169]} {assign var=catsort2 value=[224,225,226,227,228,229,230,231]} {if in_array($category->id, $catsort)} DO SOMETHING {elseif in_array($category->id, $catsort1)} DO SOMETHING ELSE {elseif in_array($category->id, $catsort2)} DO SOMETHING OTHER {ELSE} DO DEFAULT This is working fine but i have to add alot more values to more arrays Is this ok to keep in the .tpl file or is it bad practice thanks in advance mb Link to comment Share on other sites More sharing options...
NemoPS Posted July 29, 2015 Share Posted July 29, 2015 Bad practice, totally. Use a module that hooks to the closest hook, or in the header. Are you using a custom tpl? Link to comment Share on other sites More sharing options...
mickeyboy1 Posted July 29, 2015 Author Share Posted July 29, 2015 (edited) Thanks for the reply Nemo1 This code is currently in a .tpl file called from the category.tpl 1.6.0.14 version and default theme I didnt think it was good practice but unsure of how to put this in a php file and retrieve it in the category.tpl file currently on localhost to get ready to go live once everything is sorted Any help on this will be greatfully recieved thanks mb Edited July 29, 2015 by mickeyboy1 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted July 31, 2015 Share Posted July 31, 2015 If so, modify or extend categoryController.phpGet the variable there and assign it, it should be visible in your tpl if not, when including it use{include file="...etc..." myvar=$varname} THen use $myvar in the included one Link to comment Share on other sites More sharing options...
mickeyboy1 Posted August 13, 2015 Author Share Posted August 13, 2015 Thanks again for the reply Nemo1, unfortunately i have been reading and trying lots of different ways to get this to work and just cannot get my head around it. attached is some of what i have in the .tpl file and it works perfectly.... test-images.zip BUT how do i get this to work outside of the .tpl file??? Any help is greatly appreciated thanks mb Link to comment Share on other sites More sharing options...
NemoPS Posted August 14, 2015 Share Posted August 14, 2015 Just assign normal arrays on the php side$myarray = array(1,2,3,4,555,662,12,434,12,99);$this->context->smarty->assign('myarray', $myarray);Then use it with those conditions Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now