Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • tyfairclough Friend
    #202975

    I want to extend the Masshead module to use an article’s “Full article image” as it’s background image.

    Currently I have

    <div class=”jamasshead<?php echo $params->get(‘moduleclass_sfx’,”)?>” <?php if(isset($masshead[‘params’][‘background’])): ?> style=”background-image: url(<?php echo $masshead[‘params’][‘background’] ?>)” <?php endif; ?>

    but if it could automatically pull the article image if the view was an article then I would really be happy.

    Same applies for category but is less frequent.

    Thanks

    Ty

    tyfairclough Friend
    #556213

    Solved:

    I discovered there’s no option to not show the article full image. But an image being served twice on a page is only downloaded once so it doesn’t hurt to set the main image to display: none;

    .article-image-full {
    display:none;
    }

    then I made a view in mod_masshead/tmpl folder…

    <?php
    /**
    * ————————————————————————
    * JA Masshead Module for J25 & J33
    * ————————————————————————
    * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
    * @license – GNU/GPL, http://www.gnu.org/licenses/gpl.html
    * Author: J.O.O.M Solutions Co., Ltd
    * Websites: http://www.joomlart.comhttp://www.joomlancers.com
    * ————————————————————————
    */

    defined(‘_JEXEC’) or die(‘Restricted access’);
    ?>

    <div class=”jamasshead<?php echo $params->get(‘moduleclass_sfx’,”)?>”

    <?php
    // Article Image
    $article = JTable::getInstance(“content”);
    $article->load(JRequest::getInt(“id”)); // Get Article ID
    $article_images = $article->get(“images”); // Get image parameters
    $pictures = json_decode($article_images); // Split the parameters apart
    // Print the image
    echo “style=’background-image: url(“.$pictures->{‘image_fulltext’} .”)’ alt='”.$pictures->{‘image_fulltext_alt’} .”‘>”;
    ?>

    <h3 class=”jamasshead-title”><?php echo $masshead[‘title’]; ?></h3>
    <div class=”jamasshead-description”><?php echo $masshead[‘description’]; ?></div>
    </div>

    I then set the masshead to use my modified view and hey presto my fulltext image now sits behind my headline.

    My example is pretty ugly right now, but the hard work has been done.

    Credit to this site: http://www.eighttwentydesign.com/blog/all/149-how-to-get-article-s-intro-image-in-joomla-using-php for the bulk of the code.


    1. Screen-Shot-2014-11-23-at-2.36.12-AM
Viewing 2 posts - 1 through 2 (of 2 total)

This topic contains 2 replies, has 1 voice, and was last updated by  tyfairclough 9 years, 12 months ago.

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