PART SOLVED - Valid xhtml - encoding ampersand

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
lainyrache
Forum Members
Forum Members
Posts: 106
Joined: Thu Oct 05, 2006 11:27 am

PART SOLVED - Valid xhtml - encoding ampersand

Post by lainyrache »

Hi all

My website is failing xhtml validation because of a few un-encoded ampersands.
I am hoping there is a tag, or some code I can use to convert the '&' to a '&', as it works in menus and the breadcrumb trail.

It happens in 2 places:

1. in the {menutext} udt, here's the  code:

Code: Select all

global $gCms;
global $smarty;

$manager =& $gCms->GetHierarchyManager();

$var = 'root_page_menutext';
if( isset($params['assign']) && $params['assign'] != '' )
{
  $var = $params['assign'];
}
$result = "NO RESULT";
$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);
while( isset($currentNode) && $currentNode->getLevel() >= 0 )
{
    $currentContent =& $currentNode->getContent();
    $result = $currentContent->menutext();
    $currentNode =& $currentNode->getParentNode();
}
$smarty->assign($var,$result);
2. and in the form action on the search results page. eg:

Code: Select all

<form id="cntnt01moduleform_1" method="get" action="http://www.lalala.org.uk/cms1/cms2/?mact=Search%2Ccntnt01%2Cdosearch%2C0&cntnt01returnid=109&cntnt01searchinput=lorem&submit=Go&cntnt01origreturnid=15">
I'm sure I've seen the answer to this somewhere on the forum, but of course now I need it I can't find it anywhere.
Has anyone done this before?
Thanks for any help
Rachael
Last edited by lainyrache on Thu Feb 12, 2009 11:31 am, edited 1 time in total.
lainyrache
Forum Members
Forum Members
Posts: 106
Joined: Thu Oct 05, 2006 11:27 am

Re: PART SOLVED - Valid xhtml - encoding ampersand

Post by lainyrache »

Just in case anybody else is looking for this fix - I have managed to encode the ampersand in the {menutext} tag, by using cms_htmlentities

So the code for my menutext udt is now:

Code: Select all

global $gCms;
global $smarty;

$manager =& $gCms->GetHierarchyManager();

$var = 'root_page_menutext';
if( isset($params['assign']) && $params['assign'] != '' )
{
  $var = $params['assign'];
}
$result = "NO RESULT";
$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);
while( isset($currentNode) && $currentNode->getLevel() >= 0 )
{
    $currentContent =& $currentNode->getContent();
    $result = cms_htmlentities($currentContent->menutext());
    $currentNode =& $currentNode->getParentNode();
}
$smarty->assign($var,$result);
Still struggling with the ampersands in the search action!
Post Reply

Return to “Modules/Add-Ons”