I am trying to keep from repeating as much code/template as possible. I think in the end I will need 4 templates due to differences in navigation. That said, I want to re-use as much of the code as possible. So I thought I would render a page by building snippets. Then in my template page I would just call the snippet. That way if there was a change to the overall html, instead of editing 4 pages, I would only need to update the snippet that is generating the markup. -- Hopefully that made sense.
All was working fine, I was getting the output I want until I stated to see if things like metadata were working. Below is an example of what I am using to generate the <head> of my template. I tried to remove as much as possible, hopefully it will still make some sense.
MODx is generating all of the correct markup, but I am unable to set the metadata from the manager. Is it because I am asking MODx to render too many things and it’s in essence overwriting itself?
If I type in the metadata code markup (html) into the template (html) it seems to work. Has anyone had any luck doing this? Or am I just S.O.L. and have to create 4 complete templates.
Snippet "InsidePage":
function RenderPage()
{
$html = '';
$html .= '[[Head]]'."\n";
// render the snippet to the page
echo ( RenderPage() );
Snippet: "Head"
<?php
// function to render the head of the template
function RenderHead()
{
$html = '';
$html .= '<head>'."\n";
$html .= '<title></title>'."\n";
$html .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n";
$html .= '<meta name="keywords" content="" />'."\n";
$html .= '<meta name="description" content="" />'."\n";
$html .= '<link rel="stylesheet" type="text/css" media="all" href="'.LINK_CSS.'style.css" />'."\n";
$html .= '<link rel="stylesheet" type="text/css" media="print" href="'.LINK_CSS.'print.css" />'."\n";
$html .= '<link rel="shortcut icon" href="'.IMAGES.'favicon.ico" />'."\n";
$html .= '<script language="javascript" type="text/javascript" src="'.LINK_JS.'menu.js"></script>'."\n";
$html .= '<script language="javascript" type="text/javascript" src="'.LINK_JS.'DD_belatedPNG.js"></script>'."\n";
$html .= '<!--[if lte IE 6]>'."\n";
$html .= '<link rel="stylesheet" rel="stylesheet" type="text/css" media="all" href="'.LINK_CSS.'menu_ie2.css" />'."\n";
$html .= '<script src="'.LINK_JS.'DD_belatedPNG.js"></script>'."\n";
$html .= '<script>'."\n";
$html .= 'DD_belatedPNG.fix(\'#squareImage\');'."\n";
$html .= '</script>'."\n";
$html .= '<![endif]-->'."\n";
$html .= '</head>'."\n";
$html .= ''."\n";
return $html;
}
// render the snippet to the page
echo ( RenderHead() );
?>
Page Template: