Fork me on GitHub

Hack for phTheme.class.php  Bottom

  • NOTE: Please check the functionality in my next post

    Hi I write a hack for phTheme.class.php, can you review it?

    1. In the file, pnTheme.class.php, function _load_config(), After lines:

    Code

    // identify and load the correct module configuration
    $this->cachepage = true;


    Add the follow:

    Code

    // BEGIN - UM Hack
    $customargs2=$this->_check_if_exists($customargs, &$pageconfigurations);
    // END - UM Hack



    2. In the file, pnTheme.class.php, function _load_config(), replace line:

    Code

    } else if (isset($pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs])) {
                    $file = $pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs]['file'];


    By:

    Code

    /* BEGIN UM Hack
                } else if (isset($pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs])) {
                    $file = $pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs]['file'];
                */

                } else if (!empty($customargs2)) {
                    $file = $pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs2]['file'];
                // END UM  Hack


    3. In the file pnTheme.class.php add the follow method to Theme class

    Code

    /**
             * Check if exists some configuration for a specific url
             *
             * @author UNDERMEDIA S.A. <info@undermedia.com.ec>
             * @param string    $pCustomArgs    query parsed
             * @param array     $pPageConfig    the page configurations
             * @return string
             */

            function _check_if_exists($pCustomArgs, $pPageConfig)
            {
                if(trim($pCustomArgs)=="")
                    return "";
                elseif(isset($pPageConfig[$this->module.'-'.$this->type.'-'.$this->func.$pCustomArgs]))
                    return $pCustomArgs;
                else
                    return $this->_check_if_exists($this->_delete_last_arg($pCustomArgs),$pPageConfig);
            }
           
            /**
             * delete last argument from parse query
             *
             * @author UNDERMEDIA S.A. <info@undermedia.com.ec>
             * @param string $tempargs  query parsed
             * @return string
             */

            function _delete_last_arg($tempargs)
            {
                $tempargs=split("-",$tempargs);
               
                $i=count($tempargs);
                if ($i>0)
                    unset($tempargs[$i-1]);
               
                $i=count($tempargs);
                for($j=0;$j<$i;$j++)
                {
                    if(trim($tempargs[$j])!="")
                        $res .= '-'.$tempargs[$j];
                }
                return $res;
            }


    Thanks





    edited by: netoec84, Feb 24, 2007 - 06:04 PM
  • No that I can provide any suggestions, but you never mention what the hack is supposed to do.
  • Sorry, first I'm sorry for my English, it isn't so good.... ok, When I was running some modules I found a problem with page configurations of an Theme. Imagine the next case:

    If you use Pagesetter, you can create a "publication type" and in this publication you can create some "publication content", if you create two publication content (pub1 and pub2) and if you want that pub1 have their own templete you should create a page configuration like this:

    -----------------
    Module: Pagesetter
    Function type: user
    Function: viewpub
    Custom Arguments: tid=2-pid=1 (where tid=2 is the publication type -maybe a category- and pid=1 is a publication content)
    Configuration file: cfg1.ini

    And in cfg1.ini you must edit the value "Page template" to the new template that you want use (cfg1.html):
    ------------------

    It work fine!, but what happen if you want that second publication content of publication type 1 use the same template (cfg1.html)? You need do the same process but changing Custom Arguments to tid=2-pid=2 (where pid=2 is the second publication content) and if you need that all publication type use the template you must do the same process "n" times.

    I try to put only tid=2 in Custom Arguments but actually in PN .8 ms3 it dont work, so the hack permit it and also mantain the original features.

    What you think?
  • now, have you a suggestion?
  • The page configuration file selection has changed quite a bit in SVN to fix this kind of issue. Can you please check the latest daily to see if the need for this hack has been removed.

    Thanks.

    -Mark

    --
    Visit My homepage and Zikula themes.

This list is based on users active over the last 60 minutes.