We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

[Solution Available] How to create boolean flag in general.html that will be true when on user profile page? | Forum

Jason
Jason May 7 '15
I want some kind of variable to determine if I am on the user profile page.
{IsProfile}

This way when it's true I can prevent the blasted side bar from loading on the profiles. The theme I am using really missed the mark on this.

Any help? Even a full Url variable would be useful.
Thank you in advance.
The Forum post is edited by Alia May 15 '15
Jason
Jason May 7 '15
Hi Rebecca,
That's not a bad fix for a quick n dirty solution.
Thank you!

With that said, however, behind this question I really have a need for the requested flag. Most obviously because I actually don't want the data to load (as opposed to loading and just being hidden) but also I am going to break down the mechanics of how to make this flag to use it all over my site. I want the ability to know which page I am on using PHP. 

Is there any answer to my original question? can I get a flag? Or is there a URL global variable that changes per page?
Thank you in advance.
The Forum post is edited by Jason May 7 '15
Nickolay
Nickolay May 14 '15
Create new Smarty Function in /ow_smarty/plugin/function.check_profile.php:


<?php

function smarty_function_check_profile( $params, &$smarty )

{

    $request = OW::getRequestHandler()->getHandlerAttributes();

    $return = $request['controller'] == 'BASE_CTRL_ComponentPanel' && $request['action'] == 'profile';


    if(!empty($params['assign']))

        $smarty->assign($params['assign'], $return);

    else

        return $return;

}


Then you can use it like this in any template:


{check_profile assign='isProfile'}

{if $isProfile}

...

{/if}

The Forum post is edited by Nickolay May 14 '15
Alia Team
Alia May 15 '15
Alternative solution will be to assign a separate master page without sidebar to profile component panel.

By default all inner pages ( except index page customization and "blank" pages such as /sign-in, /maintenance and etc) use general.html master page (ow_themes/theme_name/master_pages). If theme comes with sidebar, this file will include:

<div class="ow_sidebar">
                        {component class="BASE_CMP_Sidebar"}
                    </div>


To remove sidebar from profile page you can assign this page another master page template without sidebar.

Try following steps:

1. Create your master page .html file. Let's name it "profile.html".
2. Copy content of general.html file into profile.html
3. Remove sidebar related <div> from  profile.html >> save your changes.

4. Open ow_system_plugins/base/controllers/component_panel.html
Within that file find:
     public function profile( $paramList )
5. Introduce your master page within this function.

$masterPageFileDir = OW::getThemeManager()->getMasterPageTemplate('profile');
            OW::getDocument()->getMasterPage()->setTemplate($masterPageFileDir);


Where profile is the name of your master page ( profile.html).
You can place this code right after: $userDto = $userService->findByUsername($paramList['username']);

6. Open theme.xml of your theme. You will need to intruduce your master page here as well. Right after  <sidebarPosition>right</sidebarPosition> add:
<masterPages>
       <base_profile_page>profile</base_profile_page>
    </masterPages>


7. Enable DEV mode in config.php file to regenerate site's cache.

To check whether modification worked, open dashboard page and any user profile page. Sidebar should not be present on profile page. But it should be on dashboard one.

Check your site throughly to make sure that everything works and don't forget to disable DEV mode.

This modification will be lost if you update core platform and your theme in future.