Comment to 'Adding custom php pages to UNA'
  • Cem that is really interesting. It will be so helpful if you can create a short tutorial on how to do this in step-by-step approach for experienced users like me.

    • Hi Scholar;

      Before all I want to remind that this is not the normal way of doing things, but I am using it cause I have no time to properly learn UNA app development.

      So lets go:

      • Studio >pages create a page -here testpage- and insert a raw block in it
        (you may put the raw block on any page, here only testing)
      • put your book mark inside the raw block here
      • take a copy of your original page php and edit your page php as follows:
        <?php
        require_once('./inc/header.inc.php');
        require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
        
        $oTemplate = BxDolTemplate::getInstance();
        $oPage = BxDolPage::getObjectInstanceByURI();
        
        $custompage=1; //with this switch you may close all your custom code and make page.php work as normal, just make it not 1 to go to normal
        if ($custompage==1){
        bx_import('BxDolLanguages');
        $uri = $_SERVER['REQUEST_URI'];
                        
        if ($oPage) {
            // $oPage->displayPage();
              $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
            $oTemplate->setPageType ($oPage->getType());
           $oTemplate->setPageContent ('page_main_code', $oPage->getCode());}
         else {
         $oTemplate->displayPageNotFound();}
                    
        ob_start();     
              $oTemplate->getPageCode();
            $pagetoedit = ob_get_clean();
        // here edit the html code on $pagetoedit variable
        // first we need to see if we are on the page that we want to insert our code, this is for not to lose time
        // we assume that we created a page testpage > page.php?i=testpage
        if stripos($uri, "testpage"){
        $newhtml="<b>Hello world!</b>"
        $editedpage=str_replace("<!--yourbookmarkXs48930-->",$newhtml,$pagetoedit);
        }
        //send the new page to browser
        echo $editedpage;
        
        }else{ //go to normal process without custom code
            if ($oPage) {
              $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
            $oTemplate->setPageType ($oPage->getType());
           $oTemplate->setPageContent('page_main_code', $oPage->getCode());
        $oTemplate->getPageCode();}
         else {
         $oTemplate->displayPageNotFound();} 
        }
        
        /** @} */
        
        
            
        
            
        
        

      you can process any code you like and return the results in your raw block.

      • that's extremely helpful, thank you very much, Cem