1
kaotik
tutorial: [pagewrap=mypage.php] in diferent modules
  • 2006/8/4 14:22

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


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:
include "functions.php";

-Now create a file called functions.php
-Add the following code to functions.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:
$xoopsTpl->assign('title'$title);
$xoopsTpl->assign('content'$content);


-replace with:
$content_wrappedpageWrap($content);
$xoopsTpl->assign('title'$title);
$xoopsTpl->assign('content'$content_wrapped);


-find:
$xoopsTpl->assign('title'$title);
$xoopsTpl->assign('content'$text);


-replace with:
$content_wrappedpageWrap($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.

2
preachur
Re: tutorial: [pagewrap=mypage.php] in diferent modules
  • 2007/1/12 18:28

  • preachur

  • Just can't stay away

  • Posts: 525

  • Since: 2006/2/4 4


I want to use this with the new mypage module..... If people could upload and wrap their existing .html websites, that would rock. I just need a hack to allow the upload of .html pages with the DHTML editor. Like the image manager but for .html pages.

It would be even cooler if they could wrap EXTERNAL content with a hack like this.... I.E. wrap a myspace profile into their XOOPS mypage page without needing an iframe.
Magick can never be restrained, but when freely given is thrice regained!

Login

Who's Online

398 user(s) are online (340 user(s) are browsing Support Forums)


Members: 0


Guests: 398


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits