User Defined Tag to call Section Title –Broken after upgrade

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
schipper
Forum Members
Forum Members
Posts: 42
Joined: Wed Dec 17, 2008 8:45 pm

User Defined Tag to call Section Title –Broken after upgrade

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

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

Post 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....
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

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

Post by spcherub »

You can also try the CGSimpleSmarty Module to pull the name of a parent section/page instead of using your own code.
schipper
Forum Members
Forum Members
Posts: 42
Joined: Wed Dec 17, 2008 8:45 pm

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

Post by schipper »

I ended up just stripping the template of the special code. Thanks for the advice though!
Locked

Return to “[locked] Installation, Setup and Upgrade”