You are not logged in.
I am trying to change the page heading and the breadcrumb text on contactsheet.tpl When I run debug there, I see there is an assigned template variable {$arrNavigationInfo} which is an array. One of the elements of the array is called "title". There is another element called "breadcrumbs" which is an array where the first element is "name". This template variable is passed to an included file where I imagine the page heading and breadcrumb are displayed. I thought it would be easy to simply change these elements and put in my own text. I have tried various ways of assigning new values but nothing seems to work. I have tried (amongst lots of others):
{$arrNavigationInfo.$title = "My Page Title"}
{assignarray var="arrNavigationInfo.title" value="My New Title"}
{assign var="arrNavigationInfo.title" value="My New Title"}
These attempts are for the simpler of the 2 variables. I was thinking that if one of the above worked I could do something like:
{assign var="arrNavigationInfo.breadcrumbs.name" value="My New Breadcrumb"}
Could someone please tell me the correct syntax for assigning a new value to an array variable.
Offline
Hi,
I think you can do this with {append}. We added this as a modification to the base Smarty distribution for this very reason, although I think Smarty 3 now includes a version of this.
In any case, the syntax is:
{append var="arrFoo" key="myKey" value="myValue" }
If you want to go a level deeper (for navInfo.breadcrumbs.name), you might need to assign the first level of the array to a temporary variable.
e.g.
{assign var="tmpBreadcrumbs" value=$arrNavigationInfo.breadcrumbs}
{append var="tmpBreadcrumbs" key="name" value="My New Breadcrumb" }
This /should/ work but please let me know how you get on.
Cheers,
Ben
Offline
Thanks Ben
The first piece works just great so I can change the page heading with:
{append var="arrNavigationInfo" key="title" value="xxx" }
However the breadcrumb is actually an array of arrays. But I took your first suggestions and worked it a bit. I came up with the following which works, but will only work as long as there is the same simple breadcrumb list. If the breadcrumb list changes this will break something. This is good enough for what i need now and I may come back here in the future.
{assign var="tmpBreadcrumbs" value=$arrNavigationInfo.breadcrumbs.0}
{append var="tmpBreadcrumbs" key="name" value="yyy" }
{assignemptyarray var="myBreadcrumb"}
{append var = "myBreadcrumb" key=0 value=$tmpBreadcrumbs}
{append var="arrNavigationInfo" key="breadcrumbs" value=$myBreadcrumb }
Last edited by mdyason (2015-11-25 20:36:17)
Offline