I originaly posted this in the documentation site, but I'll post here too in case people are searching for this.
I use smartsection (which is excelent) but for certain areas I find content 0.5 more compact and easier to handle small amounts of content. However there is a feature of smartsection that I simply cannot live without: [pagewrap=mypage.php]
So I decided to hack this feature into content. This hack is so simple you can apply it to any article or content manager.
-Go into /modules/content/index.php
-right after the include add this:
le="color: #000000"><?php include "functions.php";
-Now create a file called functions.php
-Add the following code to functions.php
<?php function pageWrap($mytext) { $maxLength=0; $format="S"; $ret = $mytext; $wrap_pos = strpos($ret, '[pagewrap='); if (!($wrap_pos === false)) { $wrap_pages = array(); $wrap_code_length = strlen("[pagewrap="); while (!($wrap_pos === false)) { $end_wrap_pos = strpos($ret, ']', $wrap_pos); if ($end_wrap_pos) { $wrap_page_name = substr($ret, $wrap_pos + $wrap_code_length, $end_wrap_pos - $wrap_code_length - $wrap_pos); $wrap_pages[] = $wrap_page_name; } $wrap_pos = strpos($ret, '[pagewrap=', $end_wrap_pos -1); } foreach($wrap_pages as $page) { $wrap_page_content = loadwrapPage($page); $ret = str_replace("[pagewrap=$page]", $wrap_page_content, $ret); } } return $ret; } function loadwrapPage($file_name) { $page =XOOPS_ROOT_PATH.'/modules/content/content/' . $file_name; if (file_exists($page)){ // this page uses smarty template ob_start(); include ($page); $content = ob_get_contents(); ob_end_clean(); return $content; } } ?>
-go back to index.php
- find:
le="color: #000000"><?php $xoopsTpl->assign('title', $title); $xoopsTpl->assign('content', $content);
-replace with:
le="color: #000000"><?php $content_wrapped= pageWrap($content); $xoopsTpl->assign('title', $title); $xoopsTpl->assign('content', $content_wrapped);
-find:
le="color: #000000"><?php $xoopsTpl->assign('title', $title); $xoopsTpl->assign('content', $text);
-replace with:
le="color: #000000"><?php $content_wrapped= pageWrap($text); $xoopsTpl->assign('title', $title); $xoopsTpl->assign('content', $content_wrapped);
That's it! you can now wrap any .html, .php page you want into your content by simply adding [pagewrap=mypage.php] in your editor.