Page 1 of 1

User Defined Tag to call Section Title –Broken after upgrade

Posted: Wed Mar 13, 2013 5:51 pm
by schipper
Hello,
I was previously running v1.5, and have successfully upgraded to v1.9.4.

With the upgrade to v1.10, i ran into the problem of not seeing any content on my page -- but it is there on the backend.

The error is see pinpoints a User Defined Tag i am running that i called {sectiontitle} which is supposed to pull the parent section name. I use it in my div id and to call a URL path to serve a certain image.

Here is the actual error code:

Code: Select all

Fatal error:  Call to a member function Execute() on a non-object in /homepages/42/d274302523/htdocs/lib/classes/class.usertagoperations.inc.php(260) : eval()'d code on line 28
Here is the {sectiontitle} User Defined Tag:

Code: Select all

    global $gCms; 
    $levels = isset($params["levels"]) ? $params["levels"] : 1 ;

        // which page are we viewing?
        $curPageID = $gCms->variables['content_id'];
        $curPage = ContentManager::LoadContentFromId($curPageID);

        // figure out the details of the current page and where it fits in
        // the content hierarchy
        $curHierarchy = $curPage->Hierarchy().'.';
        $theLevels = explode (".",$curHierarchy);
        $imSpec = $sectiontitle;
        $depth = substr_count($curHierarchy,'.');
        if ($levels < $depth)
            {
            $depth = $levels;
            }

            $hierCode = "";
            for ($j=0;$j<$depth;$j++)
                {
                $hierCode .= substr("00000",0,5-strlen($theLevels[$j])) . $theLevels[$j] . ".";
                }
            $hierCode = rtrim($hierCode,".");
            $db = $gCms->db;
            $query = "select content_alias, content_name from " . cms_db_prefix().
                "content where hierarchy=?";
            $dbresult = $db->Execute($query, array($hierCode));
            if ($dbresult && $dbresult->RecordCount() > 0)
                  {
                  $row = $dbresult->FetchRow();
                      $imSpec = strtolower($row["content_alias"]). "";
                  $imText = $row["content_name"];
                  }
    echo "${imSpec}";

I have a feeling the Database schema must have changed causing my custom code not to work. I did not write the code myself, so i can't figure out what to change! I am hoping an expert can help me!

Thanks in advance.

Re: User Defined Tag to call Section Title –Broken after upg

Posted: Wed Mar 13, 2013 8:38 pm
by Jo Morg
That particular error should be solved by swapping:

Code: Select all

$db = $gCms->db;
by:

Code: Select all

$db = cmsms()->GetDb()
But a UDT that old may have other issues....

Re: User Defined Tag to call Section Title –Broken after upg

Posted: Fri Mar 22, 2013 1:49 pm
by spcherub
You can also try the CGSimpleSmarty Module to pull the name of a parent section/page instead of using your own code.

Re: User Defined Tag to call Section Title –Broken after upg

Posted: Mon Mar 25, 2013 8:47 pm
by schipper
I ended up just stripping the template of the special code. Thanks for the advice though!