Skip to content

Instantly share code, notes, and snippets.

@larsschenk
Created May 24, 2010 12:32
Show Gist options
  • Save larsschenk/411805 to your computer and use it in GitHub Desktop.
Save larsschenk/411805 to your computer and use it in GitHub Desktop.
indexAndLayoutInOneFile.php
<?php
/**
* indexAndLayoutInOneFile.php
*
* Demo how to use one single file for layout
* within the same file.
*
* This is what TE requested for usage at CMS system RedDot to avoid different "trees".
*/
// Set the inlcude path to rendering includes.
// It's prefered to set include_path in the php.ini on production servers.
// If it's set in php.ini, you can remove the following 2 lines:
$render_include_path = "${_SERVER['DOCUMENT_ROOT']}/includes/ln/"; // <-- change if needed
set_include_path(get_include_path() . PATH_SEPARATOR . $render_include_path);
require_once ('RenderClass.inc');
class RenderClassWithLayout extends RenderClass
{
protected function xhtml_layout($content) {
/**
* This xhtml_layout function is where the webdesigner can layout the page.
* There is a $content array with several vars that can be used:
*
* $content['news'] = A single news or a list of news that matches a selection
* $content['id'] = The id of the displayed news (zero if displaying lists)
* $content['title'] = Used as pagetitle. Title of a news or selection.
* $content['keywords'] = Keywords as defined in the news plus url path.
* $content['description'] = Title of a news or title of a selection.
* $content['breadcrump'] = Breadcrump HTML snipped with links.
* $content['pixelcode'] = IVW, eTracker, GA and other pixel counter codes.
* $content['kalender'] = Calendar HTML snipped.
* $content['url_cdn'] = URL of the Content Delivery Network where static files are stored.
* $content['meta_robots'] = Default is empty = index, follow or a combination of these: http://www.robotstxt.org/meta.html
* $content['java_script'] = JavaScript Includes for the header.
* $content['java_script_body'] = additional JavaScript code that goes right after the body tag.
* $content['link_css'] = CSS Includes.
* $content['link_icon'] = Favicon.
* $content['debug'] = Debug footer.
*/
?>
<!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" xmlns:fb="http://www.facebook.com/2008/fbml" lang="de" xml:lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="de" />
<meta name="description" content="<?php echo $content['description']; ?>Nachrichten und Service für Demo und Umgebung" />
<meta name="keywords" content="<?php echo $content['keywords']; ?> Demo Nachrichten" />
<?php echo $content['meta_robots']; ?>
<?php echo $content['link_css']; ?>
<!--link rel="stylesheet" type="text/css" href="<?php echo $content['url_cdn']; ?>/cdn/css/more.css" media="screen" /-->
<?php echo $content['link_icon']; ?>
<?php echo $content['java_script']; ?>
<!--script type="text/javascript" src="<?php echo $content['url_cdn']; ?>/cdn/js/more.js"></script-->
<title><?php echo $content['title']; ?> LN-Online</title>
</head>
<body>
<?php echo $content['java_script_body']; ?>
<?php echo $content['pixelcode']; ?>
<div id="content_home">
<!--Header Anfang-->
<div id="header">
<div id="headerkasten">
<?php echo $content['kalender']; ?>
<div id="logo" onclick="location.href='http://www.ln-online.de/';"></div>
<div id="header_rechts">
<div id="kontakt">
<a href="/intern/kontakt/" class="kontakt"> Kontakt</a>
<a href="mailto:info@ln-online.de" class="mail"> Mail</a>
<a href="/lokales/google_ergebnis.htm" class="suche"> Suche</a>
</div> <!-- /kontakt -->
<div id="search">
<!-- SiteSearch Google in Kopfzeile -->
<form method="get" action="/lokales/google_ergebnis.htm" target="_top">
<input type="hidden" name="domains" value="www.LN-online.de" />
<input type="hidden" name="sitesearch" value="www.LN-online.de" id="ss2" />
<input type="hidden" name="client" value="pub-6891186480859605" />
<input type="hidden" name="forid" value="1" />
<input type="hidden" name="ie" value="ISO-8859-1" />
<input type="hidden" name="oe" value="ISO-8859-1" />
<input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#396FAC;VLC:8B0000;AH:center;BGC:FFFFFF;LBGC:FFFFFF;ALC:396FAC;LC:396FAC;T:666666;GFNT:0000FF;GIMP:396FAC;LH:35;LW:175;L:http://www.ln-online.de/cdn/layout/ln/basics/print-logo.jpg;S:http://www.ln-online.de/index.htm;FORID:11" />
<input type="hidden" name="hl" value="de" />
<input type="text" name="q" size="" maxlength="255" value="" id="sbi" style="font:10px verdana, helvetica, arial,sans serif; color:#666666; width:126; height:16; margin: 0px 1px 0 0;" /><input alt="suchen" type="image" src="<?php echo $content['url_cdn']; ?>/cdn/layout/ln/basics/button_search.gif" style="height:16px; width:14px; border:0px;" name="sa" value="Suchen" id="sbb" />
</form>
<!-- /SiteSearch Google -->
</div> <!-- search -->
</div> <!-- header_rechts -->
</div> <!-- headerkasten -->
</div> <!-- header -->
<!--Header Ende-->
<!--Navigation Anfang-->
<!-- TODO put correct navigation in here (this is just demo) -->
<div id="navigation">
<a href="/index.php" class="But01aktiv" title="Home"><span>Home</span></a>
<a href="/lokales" class="But02" title="Lokales"><span>Lokales</span></a>
<a href="/news" class="But03" title="News"><span>News</span></a>
<a href="/sport" class="But04" title="Sport"><span>Sport</span></a>
<a href="/unterhaltung" class="But05" title="Unterhaltung"><span>Unterhaltung</span></a>
<a href="/heftig" class="But07" title="Heftig"><span>Heftig</span></a>
<a href="/magazin" class="But06" title="Magazin"><span>Magazin</span></a>
<a href="/magazin/reise" class="But11" title="Reise"><span>Reise</span></a>
<a href="/maerkte" class="But08" title="Anzeigen"><span>Anzeigen</span></a>
<a href="http://video.ln-online.de" class="But09" title="Video" target="_blank"><span>Video</span></a>
<a href="#" class="But10" title=""><span>&nbsp;</span></a>
<hr class="hide" />
<!--Subnaviagtion Anfang-->
<div id="subnavigation">
<ul>
<li><a href="/intern/impressum/" class="subnav">Impressum</a></li>
<!--li><a href="/news/archiv/" class="subnav">online-Archiv</a></li-->
<li><a href="http://www.luebecker-nachrichten.de/index/epaper.html" class="subnav">E-Paper</a></li>
<li><a href="#" class="subnav"> </a></li>
</ul>
</div> <!-- /subnavigation -->
<!--Subnavigation Ende-->
</div> <!-- /navigation -->
<!--Navigation Ende-->
<hr class="hide" />
<div id="breadcrumb">
<div id="breadcrumb_content_left">
<a href="/">> Startseite</a><?php echo $content['breadcrump']; ?>
</div> <!-- /breadcrumb_content_left -->
<div id="breadcrumb_content_right">|
<a href="http://www.nordclick.de" target="_blank"><img src="<?php echo $content['url_cdn']; ?>/cdn/layout/ln/nordclick/nc_breadcrumb.gif" width="87" height="15" border="0" alt="nordclick"/></a>
<a href="http://marktplatz.nordclick.de" target="_blank">> Markt</a>
<a href="http://nordclick.immonet.de/" target="_blank">> Immo</a>
<a href="http://nordclick.motoso.de/" target="_blank">> Auto</a>
<a href="http://nordclick.stepstone.de" target="_blank">> Stellen</a>
<a href="http://www.elitepartner.de/km/coop/nordclick.do" target="_blank">> Partner</a>
<a href="http://branchenbuch.nordclick.de" target="_blank">> Branchen</a>
</div> <!-- /breadcrumb_content_right -->
</div> <!-- /breadcrumb -->
<hr class="hide" />
<div id="inhalt_links">
<?php echo $content['news']; ?>
</div> <!-- /inhalt_links -->
<div id="inhalt_rechts">
<div id="anzeigenbox_rectangle">
<div id="teaserbox_header"><h4>Demo mit eigenem Layout in der selben Datei</h4></div>
<div id="leerzeile">&nbsp;</div>
<div style="margin: 0px 8px 15px 8px;" align="left">
<b>Demo für Nachrichten-Listen und <br />
Nachrichten Volldarstellung</b><br />
<br />
Eigenes Layout kann in Methode xhtml_layout() definiert werden.<br />
<br />
<a href="/doku/rendering.php" target="_blank" class="intro">Mehr Info zum Rendering ... </a>
</div>
<div id="teaserbox_footer"><a href="/doku/rendering.php" class="teaserbox_footer" target="_blank">zur Doku</a></div>
</div>
<!-- you may insert more boxes here... -->
</div> <!-- /inhalt_rechts -->
<!--Footer Anfang-->
<div id="footer">
<a href="#top" class="toplink" title="Nach oben"><span>zum Seitenbeginn</span>&nbsp;&nbsp;&nbsp;</a>
<strong>@ LN ONLINE GMBH, 23556 LÜBECK, HERRENHOLZ 10-12</strong>
<a href="#top" class="toplink" title="Nach oben">&nbsp;&nbsp;&nbsp;<span>zum Seitenbeginn</span>&nbsp;&nbsp;&nbsp;</a>
<hr style="clear: both;" />
<p>Unternehmensgaben:
<a href="http://www.ln-online.de/intern/impressum/" class="footlink">Impressum</a> -
<a href="http://www.ln-online.de/intern/agb/" class="footlink">AGB</a> -
<a href="http://www.ln-online.de/intern/datenschutz/" class="footlink">Datenschutz</a> -
<a href="http://www.ln-online.de/intern/kontakt/" class="footlink">Kontakt</a> -
<a href="http://www.luebecker-nachrichten.de/" class="footlink" target="_blank">Unternehmensportal</a> -
<a href="http://stadtplan.ln-online.de/Luebeck/Stadtplan/cgi-bin/perl/extern/link.pl?GKx=4409982&amp;GKy=5970343&amp;Icon=LN&amp;vonWo=Objekt&amp;ID=ob21496437492" class="footlink" target="_blank">Standort</a><br />
Weitere Angebote:
<a href="http://www.ln-online.de/heftig" class="footlink" target="_blank">Heftig-Online</a> -
<a href="http://www.mast-und-schot.de/" class="footlink" target="_blank">Mast-und-Schot.de</a> -
<a href="http://pinnwand.ln-online.de/" class="footlink" target="_blank">Pinnwand</a> -
<a href="http://blog.ln-online.de/" class="footlink" target="_blank">Weblog</a><br />
<a href="http://www.ln-online.de/news/archiv/" class="footlink">Archiv</a> -
<a href="http://forum.ln-online.de" class="footlink">Chat</a> -
<a href="http://www.luebecker-nachrichten.de/index/epaper.html" class="footlink" target="_blank">ePaper</a> -
<a href="http://forum.ln-online.de" class="footlink" target="_blank">Forum</a> -
<a href="http://www.ln-online.de/newsletter " class="footlink">Newsletter</a> -
<a href="http://www.ln-online.de/news/rss_feed/" class="footlink">RSS-Feed</a> -
<a href="http://stadtplan.ln-online.de" class="footlink">Stadtplan</a> -
<a href="http://umfragen.ln-online.de/" class="footlink">Umfragen</a> -
<a href="http://www.ln-online.de/lokales/video/" class="footlink">Videonews</a> -
<a href="http://www.ostsee-zeitung.de" class="footlink" target="_blank">Ostsee-Zeitung</a>
</p>
</div> <!-- footer -->
<!--Footer Ende-->
</div> <!-- /content_home -->
<?php echo $content['debug']; ?>
</body>
</html>
<?php
} // function html_layout
} // class RenderClassWithLayout
$render = new RenderClassWithLayout();
// Advanced method to insert one or more selections
// and to add HTML code to layout $content['news'].
$render->show_options['want_selections'] = <<<EOT
<div id="news_core" class="news_core">
<h3>Demo vollständig in einer Datei</h3>
Das Layout ist hier in der Methode xhtml_layout() enthalten. Es wird hier also Layout und index.php Datei nicht mehr getrennt.<br />
Dies war ist eine Anforderung um dem CMS entgegen zu kommen und alles in einer Datei anlegen zu können.<br />
<br />
</div>
EOT;
echo $render->displayContent();
unset($render);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment