Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
GrooveOnBeat Posted July 23, 2016 Posted July 23, 2016 As a quick experiment, I dumped the entire globalTemplate content into a custom Page HTML block. I removed all contents from the globalTemplate and inserted the block key. I got this error when viewing the page (as expected): Quote [[Template core/front/global/globalTemplate is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]] What I'd like to do is simplify editing multiple templates. For example, if I have 10 templates and I want to make a change that affects all templates I have to manually edit each of the 10 templates to get the same results. If I can use Page blocks like include files, that will make editing much simpler. Then all I have to do is edit 1 Page block instead of editing 10 templates. Or is there another, and more practical way of achieving this?
Rikki Posted July 24, 2016 Posted July 24, 2016 They don't inherit variables - they have their own variable scope. What you are trying to do would probably be better accomplished by adding custom template bits to your theme. With custom templates, variables aren't inherited either, but you can pass variables into templates like so: {template="your_template" group="global" app="core" params="$var1, $var2, $etc"}
GrooveOnBeat Posted July 24, 2016 Author Posted July 24, 2016 29 minutes ago, Rikki said: They don't inherit variables - they have their own variable scope. What you are trying to do would probably be better accomplished by adding custom template bits to your theme. With custom templates, variables aren't inherited either, but you can pass variables into templates like so: {template="your_template" group="global" app="core" params="$var1, $var2, $etc"} Thanks for replying, Rikki. By custom template, do I create a new "HTML template"? In the "variables" field, can I add the variables I want to pass in there? Or is it better to add the variables in the "params" when I'm calling the template bit? If I want to use the template globally, do I choose "System" in Applications?
Rikki Posted July 24, 2016 Posted July 24, 2016 You'd need to add the params to both areas - when you create the template you specify the ones you'll be passing, and then when you actually call the template, pass the through using the params attribute. It doesn't really matter where you put your custom templates - you can call them wherever they are. I like to create a new group called custom within the System app to keep custom template bits. Then you'd call it like this: {template="your_template_key" app="core" group="custom" params="$whatever, $you, $specified"} (In case it isn't clear, the System app key is core).
GrooveOnBeat Posted July 24, 2016 Author Posted July 24, 2016 12 minutes ago, Rikki said: You'd need to add the params to both areas - when you create the template you specify the ones you'll be passing, and then when you actually call the template, pass the through using the params attribute. It doesn't really matter where you put your custom templates - you can call them wherever they are. I like to create a new group called custom within the System app to keep custom template bits. Then you'd call it like this: {template="your_template_key" app="core" group="custom" params="$whatever, $you, $specified"} (In case it isn't clear, the System app key is core). YOU ROCK, RIKKI! Thanks a bunch! I don't want to jinx anything but I think it's working. I created the template and as a test I copied the entire contents of globalTemplate and added them into my custom template. Then I removed everything in globalTemplate, and added my template key. It's working so far, no errors! I say I don't want to jinx anything because it's a feeling like it's too good to be true. Here's my template below. I added "location" to it since I left it in the existing global location. {template="testGlobalTemplate" app="core" location="global" group="custom" params="$title,$html,$location=array()"} With this adds many other things I've wanted to do. Thank you!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.