Change Top Menu Title on Module

Hello Dolphineers again. I am having a brain fart. I started creating a new module the other night that is based off of the Groups module. So far, everything has gone smoothly and the module is working great. I just have one small item that I am trying to resolve, and I know it is probably something obvious, and I may be over-thinking things.

In my new module, I added 2 fields (First Name and Last Name) to the bx_groups_main (equivalent) table. In the Top Menu, I would like to show those variables instead of the Group Title, and the same on the browser tab. See uploaded pic for clarification. Any help in finding where I would need to change the code would be greatly appreciated. Thanks in advance.

Top Menu Changes.jpg · 374.6K · 135 views
caredesign.net
Quote · 5 Dec 2013

I found how to change the Title in the browser tab, so scratch that one.

caredesign.net
Quote · 5 Dec 2013

OK, still having issues with getting name to appear in breadcrumb. Here is what I have tried:

First off, I have this in my CfClientsDb.php page in the classes folder (I have removed the extra items as they are not in question):

function CfClientsDb(&$oConfig)
    {
        parent::BxDolTwigModuleDb($oConfig);

        $this->_sTableMain = 'main';
        $this->_sFieldTitle = 'title';
        $this->_sFieldFirstName = 'firstname';
        $this->_sFieldLastName = 'lastname';
    }

If I do this, then I can get the last name to show up fine in the breadcrumb:


        $this->_sTableMain = 'main';
        $this->_sFieldTitle = 'lastname';
        $this->_sFieldFirstName = 'firstname';
        $this->_sFieldLastName = 'lastname';

 

So, how would I go about making both of the field entries show in the title variable? I have tried the following:


1.        $this->_sFieldTitle = 'lastname' 'firstname';     

2.        $this->_sFieldTitle = 'lastname', 'firstname';

3.        $this->_sFieldTitle = $this->_sFieldFirstName . ' ' . $this->_sFieldLastName;

4.        $name = $this->_sFieldFirstName . $this->_sFieldLastName;

           $this->_sFieldTitle = $name;

5.        $name = $this->_sFieldFirstName . ' ' . $this->_sFieldLastName;

           $this->_sFieldTitle = $name;

6.        $name = $this->_sFieldFirstName . " " . $this->_sFieldLastName;

           $this->_sFieldTitle = $name;

There were several more that I tried but they all had the same results - it did not work.

My only other thought was to take the first name and last name when submitted in the form and have those entered into the database title field. If anyone could help me figure out either way, I would greatly appreciate it.

caredesign.net
Quote · 5 Dec 2013

Just bumping in case anyone knows the answer to this one.

caredesign.net
Quote · 9 Dec 2013

Ok.

1.        $this->_sFieldTitle = 'lastname' 'firstname';
2.        $this->_sFieldTitle = 'lastname', 'firstname';

1 and 2 invalid because it is not valid php code.

3.        $this->_sFieldTitle = $this->_sFieldFirstName . ' ' . $this->_sFieldLastName;

3 should work, but it depends on where the code is.

$this->_sTableMain = 'main';
        $this->_sFieldTitle = 'title';
        $this->_sFieldFirstName = 'firstname';
        $this->_sFieldLastName = 'lastname';

Here your asigning the title before the first and last name, so if 3 is what your using at this $this->_sFieldTitle = 'title'; location than it will not work becuse your calling on the contents of variables you have not assigned yet,

4.        $name = $this->_sFieldFirstName . $this->_sFieldLastName;

           $this->_sFieldTitle = $name;

5.        $name = $this->_sFieldFirstName . ' ' . $this->_sFieldLastName;

           $this->_sFieldTitle = $name;

6.        $name = $this->_sFieldFirstName . " " . $this->_sFieldLastName;

           $this->_sFieldTitle = $name;


Same as 3. should work if it's in the right spot. Must be located in the code after the code that fills the first and last name variables.

So, rearainge this block of code to something line this.

        $this->_sTableMain = 'main';
        $this->_sFieldFirstName = 'firstname';
        $this->_sFieldLastName = 'lastname';
        $this->_sFieldTitle = $this->_sFieldFirstName . ' ' . $this->_sFieldLastName;

This way first and last are set before the title so the variables actually contain something before you try to use them.

https://www.deanbassett.com
Quote · 9 Dec 2013

After taking some time to work on some other things, I have returned back to this situation and have finally found a solution. Unfortunately, the original thoughts on putting the First and last name was not working, although I had things in the correct order (thanks deano for the help).

My end resloution ended up being the following. On my CfNetworksModule.php page (equivalent of the BxGroupsModule.php page), I added the following function:



    function _preProductTabs ($sUri, $sSubTab = '')
    {
        if ($GLOBALS['oTemplConfig']->bAllowUnicodeInPreg)
            $sReg = '/^[\pL\pN\-_]+$/u'; // unicode characters
        else
            $sReg = '/^[\d\w\-_]+$/u'; // latin characters only

        if (!preg_match($sReg, $sUri)) {
            $this->_oTemplate->displayPageNotFound ();
            return false;
        }

        if (!($aDataEntry = $this->_oDb->getEntryByUri($sUri))) {
            $this->_oTemplate->displayPageNotFound ();
            return false;
        }

        if ($aDataEntry[$this->_oDb->_sFieldStatus] == 'pending' && !$this->isAdmin() && !($aDataEntry[$this->_oDb->_sFieldAuthorId] == $this->_iProfileId && $aDataEntry[$this->_oDb->_sFieldAuthorId]))  {
            $this->_oTemplate->displayPageNotFound ();
            return false;
        }

        $GLOBALS['oTopMenu']->setCustomSubHeader($aDataEntry[$this->_oDb->_sFieldFirstName] . ' ' . $aDataEntry[$this->_oDb->_sFieldLastName]);
        $GLOBALS['oTopMenu']->setCustomVar($this->_sPrefix.'_view_uri', $aDataEntry[$this->_oDb->_sFieldUri]);
        $GLOBALS['oTopMenu']->setCustomBreadcrumbs(array(
            _t('_'.$this->_sPrefix) => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'home/',
            $aDataEntry[$this->_oDb->_sFieldTitle] => $sSubTab ? BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aDataEntry[$this->_oDb->_sFieldUri] : '',
            $sSubTab => '',
        ));

        if ((!$this->_iProfileId || $aDataEntry[$this->_oDb->_sFieldAuthorId] != $this->_iProfileId) && !$this->isAllowedView($aDataEntry, true)) {
            $this->_oTemplate->displayAccessDenied ();
            return false;
        }

        return $aDataEntry;
    }

 

This is copied from the BxDolTwigModule.php page with the changes in blue.

Now I have the first Name and Last Name displayed in both the Browser Tab and the SubMenu area. See Image attached. Areas circled in Black are the name, and the area circled in green is the random characters for the title and uri, but only visible in the uri.

I am using a random character generator code to create an 8 character ID which is used to fill in for the Title, which in turn creates the URI. I think this is better especially if the user adds entries of persons with the same first and last names - such as John Smith.

network.png · 170.9K · 124 views
caredesign.net
Quote · 2 Jan 2014
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.