Page 1 of 1

[solved] User defined tag cause issues after upgrade

Posted: Mon Aug 19, 2013 4:37 pm
by Weon
Hi there

I have just carried out a lengthy upgrade process from 1.9.2 to 1.11.7 and gone through clearing up all the issues. The main one was {stylesheet} to {cms_stylesheet}!

However, I have an issue with a UDT I have set up called child_content_overview that displays the name and start of the content for all child pages of the current page, in a list.

When I try to edit a template that has this UDT in, it causes errors when saving. It looks like exactly the same issue as the stylesheet issue but if I correct the stylesheet reference and remove the {child_content_overview} then the template saves fine.

The UDT itself seems to be working fine and I can edit that no problem so can anyone see a reason why the UDT reference would mean the template wouldn't save?

In case it helps, the UDT code is:

Code: Select all

global $gCms;

$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);

$nodes = $currentNode->getChildren();

if ($currentNode->hasChildren()) {
	foreach ($nodes as $node) {
		$content= $node->getContent();
		if ($content->Active()){
		
			$page_alias = $content->Alias();
			$cgsimple = $smarty->get_template_vars('cgsimple');
			$Sum = $cgsimple->get_page_content($page_alias, 'extra1');
			
			$url = $content->GetURL();
			if ($url == "#") { /* section header has no link by default */
				$url = "index.php?page=".$content->Alias();
			}
			
			echo "<h3><a href=\"".$url."\"  title=\"".$content->TitleAttribute()."\">".$content->MenuText()."</a></h3>\n";
			echo "<p>".$Sum." <a href=\"".$url."\"  title=\"".$content->TitleAttribute()."\">[read more...]</a></p>\n";
			
		}
	}
}
One of the templates it's used in is:

Code: Select all

{process_pagedata}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<__html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>{sitename} - {title}</title>
{metadata}
{cms_selflink dir="start" rellink=1}
{cms_selflink dir="prev" rellink=1}
{cms_selflink dir="next" rellink=1}
{* Relational links for interconnections between pages, good for accessibility and Search Engine Optmization *}
{cms_stylesheet}

<!--[if IE]>
{cms_stylesheet name="CCC IE Fix"}
<__script__ type="text/javascript" src="modules/MenuManager/CSSMenu.js"></__script>
<![endif]-->
{* The above JavaScript is required for CSSMenu to work in IE *}

</head>
</__body>
		<div id="pageholder">
			<div id="header">
				<h1><a href="/" title="Return to home page"><span></span>{sitename}</a></h1>
				<div id="phonenumber"><span></span>For appointments or enquiries call 01285 658796</div>
			</div>
			{menu template='CCC Top Menu'}
			<div id="content">
				<div id="sidenavcol" class="columnleft">
					<h4><span></span>In this section</h4>
					{menu template="CCC Side Menu" start_element=$friendly_position|truncate:1:""}
				</div>				
				<div id="pagecopy" class="columnleft">
					<h2>{title}</h2>
					{content}

					{child_content_overview}
				</div>
				
				<div id="fourboxcol" class="columnleft zeromargins">
{global_content name="FourBoxOut"}
				</div>
				<hr />
			</div>
			<div id="footer">
				{global_content name="Footer"}
			</div>
		</div>
	<__body>
</__html>
I'm tearing my hair out because I've been looking through the documentation and I can't see anything wrong.

If anyone can help I would really appreciate it!

Re: User defined tag cause issues after upgrade

Posted: Mon Aug 19, 2013 4:38 pm
by Weon
To see the UDT in action, take a look at http://cirencesterchiropractic.co.uk/nutrition.html

Re: User defined tag cause issues after upgrade

Posted: Mon Aug 19, 2013 4:49 pm
by calguy1000
Your UDT isnt doing enough error checking and is relying on smarty variables from third party modules that may or may not exist.

Re: User defined tag cause issues after upgrade

Posted: Mon Aug 19, 2013 4:50 pm
by calguy1000
Why not just use menumanager.

Re: User defined tag cause issues after upgrade

Posted: Mon Aug 19, 2013 4:54 pm
by Dr.CSS
Read the what we broke here as there may be calls in your UDT that no longer work is they are and need to be changed...

http://forum.cmsmadesimple.org/viewtopi ... =1&t=57370

Re: User defined tag cause issues after upgrade

Posted: Mon Aug 19, 2013 7:50 pm
by Weon
Thanks for your help guys.

CalGuy - I have now switched to MenuManager. I'm pretty sure that I tried that route when I first set the site up 5 years ago but at that time I couldn't use MenuManager to display the text stored in Extra1. When I went into MenuManager this time I actually had a menu I had started to set up all that time ago that almost did what I wanted so I can only assume that I abandoned it when it didn't work!

DrCSS - I read through that. Having made the only change I could see was needed it still didn't work!

Re: [solved] User defined tag cause issues after upgrade

Posted: Thu Aug 29, 2013 6:15 am
by hexdj
Could u please post your solution? Thanks.

Re: [solved] User defined tag cause issues after upgrade

Posted: Thu Aug 29, 2013 9:23 am
by Weon
Sure. I created a new menu in Menu Manager called CCC Child Overview:

Code: Select all

{if $count > 0}
  {foreach from=$nodelist item=node}
    {if $node->current != true}
      <h3><a href="{$node->url}">{$node->menutext}</a></h3>
      <p>{$node->extra1} <a href="{$node->url}">[Read more...]</a></p>
    {/if}
  {/foreach}
{/if}
I then called it in my template like this:

Code: Select all

{menu template="CCC Child Overview" start_element=$friendly_position number_of_levels="2"}
It's pretty simple and I'm sure it could be a bit cleaner but it works.

Re: [solved] User defined tag cause issues after upgrade

Posted: Thu Aug 29, 2013 5:15 pm
by hexdj
Thanks for adding your code!

Re: [solved] User defined tag cause issues after upgrade

Posted: Thu Aug 29, 2013 6:39 pm
by Weon
No problem, I hope it helped! ;)