Page 1 of 1

section title & MLE

Posted: Fri Sep 19, 2008 8:41 am
by jd
Hi,

I'm using the the {sectiontitle} plugin, but it seem that it only gets the default language's title of a section.
Can you help fix this? I got a website in ENG & BG.

Here is the plugin:

Code: Select all

function smarty_cms_function_sectiontitle($params, &$smarty)
{
    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}";
}

Re: section title & MLE

Posted: Fri Sep 19, 2008 3:39 pm
by alby
jd wrote: I'm using the the {sectiontitle} plugin, but it seem that it only gets the default language's title of a section.
I see that display content_alias only and this param is same for each languages ....

Alby

Re: section title & MLE

Posted: Thu Sep 25, 2008 1:43 pm
by jd
Nope - it display's the title of the section. For instance it is in cyrilic. The aliases can't be in Cyrilic so it's not the alias.

Re: section title & MLE

Posted: Thu Sep 25, 2008 2:03 pm
by alby
jd wrote: Nope - it display's the title of the section. For instance it is in cyrilic. The aliases can't be in Cyrilic so it's not the alias.
If you have modify this tag with echo "${imText}" ok but if you have echo "${imSpec}" for me is alias name ( $imSpec = strtolower($row["content_alias"]). ""; )
however strange tag ....

Alby

Re: section title & MLE

Posted: Thu Sep 25, 2008 2:31 pm
by alby
THIS IS UNTESTED!
.................
global $mleblock;
            $query = "select content_alias{$mleblock} as content_alias, content_name{$mleblock} as 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}";
    echo ((isset($params["display"]) && $params["display"] == 'title') ? $imText : $imSpec);
.................
{sectiontitle display='title'}

Alby