Skip to main content

#98 Delete title and link on the contest menu link

Posted in ‘NorrCompetition’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information (available for public)

PHP version
7.4

Latest post by b2z on Wednesday, 20 March 2024 13:54 EET

webquality

In fact I just noticed that for my use of the component the gallery module and the competition menu link both do part of what I want.
In the module that displays the gallery, you can remove the title from the display and delete the links that are on the image.
In the menu links which displays the competition, there are the share and vote buttons located below the photo.

So I would need a mixture of the two to achieve what I want as a display.

I will only keep the competition menu link and I will not use the module.
But I would need to be able to remove the title at the bottom of the image and remove the link on the image.

And if possible add button for download the picture.

 

Could you help me with this?

 

https://postimg.cc/kRcCqpM1

b2z

You can override /layouts/partials/grid/entry.php and modify it for your needs.

Kind regards,

Dmitrijs

webquality

I have hidden the title and removed the possibility of clicking on the photo.

On the other hand, I am stuck on the function to find the image associated with the post.
How can I make the download button link to the correct image to download automatically?

b2z

To find the image you will need CompetitionHelperExtension::getPhotoUrlPath(), for example

$image = CompetitionHelperExtension::getPhotoUrlPath($item->competition_id, $item->id, $item->image, 's', $cType);

Here is the docs:

 * Gets the participant's photo URL path.
 *
 * @param   int       $competitionId       The competition id.
 * @param   int       $participantId         The participant id.
 * @param   string  $filename                The filename without prefix.
 * @param   string  $size                        The size of the photo:  s - small (default), m - medium, l - large, o - original
 * @param   string   $competitionType  The type of competition.
 * @param   boolean  $gallery                True for gallery photo.
 */
public static function getPhotoUrlPath($competitionId, $participantId, $filename, $size = 's', $competitionType = 'photo', $gallery = false)

 

Kind regards,

Dmitrijs

webquality

Where are these buttons managed?

I want to put everything at the same level, whether in the image view or below.

But in the same place ;)

 

https://postimg.cc/jnS81LDR

 

b2z

Buttons are here /layouts/default/partials/buttons/actions.php

Kind regards,

Dmitrijs

webquality

So I deleted the modification that I had made in /layouts/partials/grid/entry.php to add the button since it is no longer useful.

 

I commented in <div class="uk-card-body"> to hide the title:

    <!-- 
	<a class="uk-text-large<?php echo $titleClass; ?>" href="https://norrnext.com/<?php echo $href; ?>">
		<?php echo $this->escape(CompetitionHelperExtension::truncate($item->title, $titleLength)); ?>
    </a>
    -->

I deleted in <div class="uk-card-media-top"> to remove the link:

href="https://norrnext.com/<?php echo $href; ?>"

 

I created a file : download.php in /layouts/default/partials/buttons/

<?php
defined('_JEXEC') or die;

use Joomla\CMS\Router\Route;

// Récupération des données transmises au layout
extract($displayData);

// Construction de l'URL de l'image
$imageUrl = CompetitionHelperExtension::getPhotoUrlPath($item->competition_id, $item->id, CompetitionHelperExtension::getParticipantImage($item), 'l', $cType);
$downloadFileName = basename($imageUrl); // Optionnel, pour spécifier un nom de fichier lors du téléchargement

echo '<a href="https://norrnext.com/' . htmlspecialchars($imageUrl) . '" download="' . htmlspecialchars($downloadFileName) . '" class="nc-share-button uk-button uk-button-default uk-padding-remove uk-width-1-' . $width . '"> <span uk-icon="icon: download"></span> Télécharger </a> </a>';

 

I changed the actions.php file (To have a different view and display the download button)

<?php
/**
 * @package    Norr_Competition
 * @author     Dmitrijs Rekuns <support@norrnext.com>
 * @copyright  Copyright (C) 2015 - 2024 NorrNext. All rights reserved.
 * @license    GNU General Public License version 3 or later; see license.txt
 */

\defined('_JEXEC') or die;

use Joomla\CMS\Router\Route;
use Joomla\Registry\Registry;

extract($displayData);

/**
 * $displayData
 *
 * @var  string    $cType          Contest type
 * @var  boolean   $isList         Is it a list of entries
 * @var  object    $item           Contest entry
 * @var  Registry  $params         Contest params
 * @var  boolean   $showVote       Display vote button or not
 * @var  boolean   $showShare      Display share button or not
 */
 
 
// Début du conteneur de grille pour les boutons
echo '<div class="uk-grid-small" uk-grid>'; // Utilise 'uk-grid-small' pour un petit espacement entre les boutons

// Bouton de vote (20%)
if ($showVote) :
    echo '<div class="uk-width-1-5">'; // Prend 20% de l'espace
    echo CompetitionHelperTheme::renderLayout('buttons.vote', [
        'item'          => $item,
        'params'        => $params,
        'showShare'     => $showShare,
        'isList'        => $isList
    ]);
    echo '</div>';
endif;



// Bouton de partage (40%)
if ($showShare) :
    echo '<div class="uk-width-2-5">'; // Prend également 40% de l'espace
    $share = $params->get('share');
    if (!empty($share)) :
        echo CompetitionHelperTheme::renderLayout('buttons.share', [
            'img'      => CompetitionHelperExtension::getPhotoUrlPath($item->competition_id, $item->id, CompetitionHelperExtension::getParticipantImage($item), 'l', $cType),
            'url'      => CompetitionHelperExtension::getRootUrl() . Route::_(CompetitionHelperRoute::getEntryRoute($item->id . ':' . $item->alias, $item->competition_id)),
            'title'    => $item->title,
            'share'    => $share,
            'showVote' => $showVote,
            'isList'   => $isList,
            'entryId'  => $item->id
        ]);
    endif;
    echo '</div>';
endif;


// Bouton de téléchargement (40%)
// Affichage direct sans condition
echo '<div class="uk-width-2-5">'; // Prend 40% de l'espace
echo CompetitionHelperTheme::renderLayout('buttons.download', [
    'item'    => $item,
    'cType'   => $cType,
    'params'  => $params,
]);
echo '</div>';

echo '</div>'; // Fin du conteneur de grille

 

And here is the final result. : https://postimg.cc/N2gdDJrn

Do you see any errors or improvements?

b2z

Download button is a direct link to photo?

webquality

This is a direct link to the photo in high quality but not the original.
The link is generated using information from:

CompetitionHelperExtension::getPhotoUrlPath
CompetitionHelperExtension::getParticipantImage

Did I make a mistake somewhere?
Everything in my house is functional at the moment.

b2z

No, it is ok :) Probably we need to take your code for improvements :)

Kind regards,

Dmitrijs

Support information

Support hours: You can get our help: Monday - Friday / 09:00 to 17:00 (GMT+3), but not limited. Our staff is pleased to provide Premium support to every paid subscriber asap, but sometimes you should be ready to wait for our reply for up to 3 days.


Our time: / Your time:

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. We also ask you to remove temporary credentials at your site after the problem is resolved. Thank you.

Support of free extensions is not provided on this forum. Please submit your questions or report issues via Github tracker. See link on the product page.