test
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • dsinor Friend
    #1017369

    Hello,

    I need php assistance within T3 using t3_bs3_blank. I’m not a coder, so I need help customizing header.php

    My goals:

    1 – replace static logo image with randomly selected image from images/random folder.

    2 – preserve ‘sm’ logo-image responsive capability for small screens.

    Background:

    1 – I copied /template/tpls/blocks/header.php to /template/local/tpls/blocks/header.php.

    2 – Local header.php – I removed the calls for Head Search and Language Switcher, and added img-responsive for the logo-images.

    3 – Now my header consists only of a single image, with local/variables.less styling of T3logowidth: 100%, height: auto.

    4 – I created /images/random/ folder, and placed three different images 1200×169 in that folder.

    5 – I created /images/random/sm/ folder and placed three different images 500×169 in that folder.

    Then I added two scripts for random image selector to the local header.php file: one for standard image size and another for sm image size.

    Then I edited the header.php code to call for the generated randomImage or randomimageSm, instead of calling for logo.png or logo-sm.png.

    It doesn’t work. 🙂

    There are no error codes, which I think must be a good thing, but the result on the page is the "alt" outcome.

    I am missing one or two critical issues somewhere.

    Here is a copy of my local header.php file:

    <?php
    
    defined('_JEXEC') or die;
    
    // get params
    $sitename = $this->params->get('sitename');
    $slogan = $this->params->get('slogan', '');
    $logotype = $this->params->get('logotype', 'text');
    
    $imagesDir = 'images/random/';
    $images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
    $randomImage = $images[array_rand($images)];
    $logoimage = $logotype == 'image' ? $this->params->get('randomImage') : '';
    
    $imagesDirSm = 'images/random/sm/';
    $imagesSm = glob($imagesDirSm . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
    $randomImageSm = $images[array_rand($imagesSm)];
    $logoimgsm = ($logotype == 'image' && $this->params->get('enable_logoimage_sm', 0)) ? $this->params->get('randomImageSm') : false;
    
    if (!$sitename) { $sitename = JFactory::getConfig()->get('sitename'); }
    
    $logosize = 'col-sm-12';
    
    ?>
    
    <header id="t3-header" class="container t3-header"> <div class="row">
        <!-- LOGO -->
        <div class="col-xs-12 <?php echo $logosize ?> logo">
            <div class="logo-<?php echo $logotype, ($logoimgsm ? ' logo-control' : '') ?>">
                <a href="<?php echo JUri::base() ?>" title="<?php echo strip_tags($sitename) ?>">
                    <?php if($logotype == 'image'): ?>
                        <img class="logo-img img-responsive" src="<?php echo JUri::base(true) . '/' . $logoimage ?>" alt="<?php echo strip_tags($sitename) ?>" />
                    <?php endif ?>
                    <?php if($logoimgsm) : ?>
                        <img class="logo-img-sm img-responsive" src="<?php echo JUri::base(true) . '/' . $logoimgsm ?>" alt="<?php echo strip_tags($sitename) ?>" />
                    <?php endif ?>
                    <span><?php echo $sitename ?></span>
                </a>
                <small class="site-slogan"><?php echo $slogan ?></small>
            </div>
        </div>
        <!-- //LOGO -->
    </div>

    I have exceeded the limit of my minimal php capabilities. 🙂 If any php experts here can suggest how to make this work, I would be very grateful!

    Perhaps i need to change the local variables.less line: @t3-logo-image: "@{t3-image-path}/logo.png"; but I am not sure about the disconnect between the random image selector and this line.

    I have succeeded in using the T3 Random Image module placed in the header, but it has two problems. It is not responsive, and it does not allow for a smaller image to be called below a certain media breakpoint. I did find a suggestion online for how to make Random Image module responsive, but it requires a modules/mod_random_image/tmpl/default.php edit, which will not survive framework/template updates.

    My site exists only on xampp on my personal machine, but I don’t think site access is needed for my problem.

    Lastly, I don’t have a custom.css file. I have accomplished a great deal with my site, including a scrolling-then-sticky navbar, using only "local" LESS customizations, the T3 Documentation, and a few "local" php tweaks.

    Thanks in advance!

    Saguaros Moderator
    #1017722

    Hi,

    You should try your script with default Joomla template first to make sure that it works or not.

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

This topic contains 1 reply, has 2 voices, and was last updated by  Saguaros 7 years, 9 months ago.

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