test
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • bulgin Friend
    #151252

    In the old ja_purity you could open the index.php file and insert code to programmatically show modules based on whether or not someone was logged in, etc.

    Where does this action take place now? I see the index.php file is not what it used to be (which is good) but where do I start looking to add code to programmatically show/hide modules based on certain conditions?

    Thank you.

    John Wesley Brett Moderator
    #344363

    In the Administrator area…simply goto and open the module you want to selectively show.

    On the left side you will see “ACCESS LEVEL” set this to the level of access a user must have in order to see the module…and *poof* you’re done!
    See Attachment….

    You can also set this by simply clicking on the link in the Module Manager under the ACCESS LEVEL column. Repeatedly clicking on the link change the access level.

    Simpler!

    bulgin Friend
    #344429

    I meant coding beyond choosing access level. There is php code that will selectively allow me to show or hide a module based on whether or not, for example, a user is logged, or if they are on the front page, or if a certain component is being displayed.

    Your solution only works based on access level.

    My original question was where do I input this type of code? It used to be that you could put it in the index.php, but I see in this template the index.php would not be a suitable area.

    Thanks.

    John Wesley Brett Moderator
    #344431

    Well now you have me curious!
    Care to share with us the code and then perhaps we can better understand what it does that Joomla doesn’t.

    Thanks!

    bulgin Friend
    #344450

    <?php if ($option != "com_componentname") : ?>
    CALL TO LOAD MODULES
    <?php endif; ?>

    or perhaps something like this:

    <!-- If the task is neither detail nor edit -->
    <?php if ($task != "detail" && $task != "edit") ?>
    <div class="collapsiblecolumn">
    <jdoc:include type="modules" style="jarounded" name="right" />
    </div>
    <?php endif; ?>

    Question is: where would I go about putting this code? As mentioned previously, it used to be easily done by inserting it in the index.php file. Now I don’t know where to put this code in this new wonderful template.

    Thanks.

    toymaker Friend
    #344452

    That kind of code goes directly inside the blocks folder into the block file (yourblock.php). Inside you will recognize the normal module codes you are used to see and edit.
    Your past index.php file is now a Layout (default.php) and the layout is built from blocks (the php files inside the blocks folder).

    If for example you want to selectively change something with the search module, you would go to the
    /layouts/blocks/header.php file and place your code in the search code area. (It obviously depends on the template you are using)

    Check out the T3 documentation for a better understanding of how your page is built using layouts and blocks.
    If you have any doubts, drop me a line!

    Peace,
    Gabriel

    bulgin Friend
    #344453

    Thank you! That was exactly what I was looking for!

    Peace.

    bulgin Friend
    #344466

    I’ve found the bit of code within the main-rounded.php file that controls the left column modules.

    That code looks like this:

    <?php if($this->countModules($inset1)) : ?>
    <div class="ja-col column ja-inset1" style="width:<?php echo $this->getColumnWidth('i1') ?>%">
    <jdoc:include type="modules" name="<?php echo $inset1;?>" style="JArounded" />
    </div>
    <?php endif; ?>

    </div>

    If I remove that code, the modules disappear, but what I need to also have happen is for that column to collapse so that the main content now jumps over and fills in that area with its content.

    Any ideas on how that might be done?

    Thank you.

    toymaker Friend
    #344475

    I see what you mean. The thing is that the column width is calculated based on the module positions that are defined at the top of your layout file (default.php). So this line is actually getting a calculated width percentage:

    <div id="ja-content" class="column" style="width:<?php echo $this->getColumnWidth('cw') ?>%">

    In your case, and because the inset1 position is not empty, the 100% width turns into 67%.
    To fix this, you could give some kind of logic to this file and let the width value know it should be 100% because in fact, you are in article view.

    There are tons of different ways to do this… but I know you can figure the best way for you. 🙂
    For example, you could set an if else clause inside the code line I just referenced so that the width is set to 100% if your view is an article. Kind of messy if you start doing this with a whole lot of modules.. but it works.

    A completely awesome fix for this would be to code the T3 template config window where you define layout overrides and make it accept views. Today you can define components and article ids only. This way you could change the whole layout depending on the views parameter. That would be a great fix!

    Hope it helps!
    Peace,

    Gabriel

    toymaker Friend
    #344476

    After an extra shot of Redbull I actually thought of a better way to deal with this in the meantime.

    Forget everything I said about calculating the width…

    Open your default layout file and go to line 34 or so.. just before the $this->definePosition ($positions); code and add the following:
    (I’ll be duplicating the right position just for testing purposes… change to suit your needs.)

    $view = JRequest::getVar('view', 0);
    if ($view == "article") {
    $positions = array (
    'inset1' =>'right'
    );
    }

    Here you are inserting your site’s show/hide module conditional logic right before the positions get processed. You can do whatever you like in here and add all the position changes you like. You don’t have to change anything else.

    In this example you will be hiding inset1 whenever you enter view mode.

    Love Redbull :laugh:

    Peace,
    Gabriel

Viewing 10 posts - 1 through 10 (of 10 total)

This topic contains 10 replies, has 3 voices, and was last updated by  toymaker 14 years, 7 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum