Jump to content

Pagination des liste marques, page custom.


jat

Recommended Posts

Bonjour,

J'aurais souhaité créer une pagination des liste marques. Mais je ne sais pas comment faire la pagination dans Prestashop.

J'ai créé une page (custom) dans prestashop, je partage le code avec vous: https://github.com/jatniel/custom_page_prestashop

Pour montrer les marques, j'ai utilisé le code suivant :

BrandsController.php: 

    public function initContent()
    {

        $brands = $this->getBrands();

        $this->context->smarty->assign('lorem', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis lacinia massa. 
        Fusce ante purus, aliquet eget porttitor ut, sodales in risus. Nunc gravida ipsum id gravida pretium.');

        $this->context->smarty->assign($brands);

        parent::initContent();

        $this->setTemplate('brandschr.tpl'); // themes/mytheme/templates/brandschr.tpl

    }

    public function getBrands(){

        $brands = Manufacturer::getManufacturers(false, (int)Context::getContext()->language->id);

        foreach ($brands as &$brand) {
            $brand['image'] = $this->context->language->iso_code.'-default';
            $brand['link'] = $this->context->link->getManufacturerLink($brand['id_manufacturer']);
            $fileExist = file_exists(
                _PS_MANU_IMG_DIR_ . $brand['id_manufacturer'] . '-' .
                ImageType::getFormattedName('medium').'.jpg'
            );

            if ($fileExist) {
                $brand['image'] = $brand['id_manufacturer'];
            }
        }

        return  array(
            'brands' => $brands,
            'page_link' => $this->context->link->getPageLink('manufacturer'),
            'text_list_nb' => Configuration::get('BRAND_DISPLAY_TEXT_NB'),
            'brand_display_type' => Configuration::get('BRAND_DISPLAY_TYPE'),
            'display_link_brand' => Configuration::get('PS_DISPLAY_SUPPLIERS'),
        );
    }

brandsjat.tpl:

<div class="row">
    {foreach from=$brands item=brand}
    {* BOX BRAND *}
        <div class="col-md-5 mt-md-5 border border-dark mx-auto l-3">
            <div class="float-left w-50">
                <img src="{$urls.img_manu_url}{$brand.image}.jpg" class="img-fluid w-75 my-5">
            </div>
            <div class="float-right w-50">
                <h2 class="text-break text-lg-center">{$brand.name}</h2>
                    <p>
                        {if !empty($brand.short_description)}
                            {$brand.short_description|strip_tags:'UTF-8'|truncate:266:'...'}
                        {else}
                            {$lorem}
                        {/if}
                    </p>
                <a href="{$brand.link}" class="">Voir tous les produits</a>
            </div>
        </div>
    {* END BOX BRAND *}
    {/foreach}
</div>

Vous pouvez m'aider à créer la pagination dans prestashop?

merci à tous! 😊

 

Prestashop v. 1.7.6.7

Edited by jat (see edit history)
Link to comment
Share on other sites

Le 28/11/2020 à 3:18 PM, Rajameltine a dit :

Bonjour,

il me semble que prestashop a déjà un TPL qui affiche la liste des marques. Inspire toi de ce TPL.

Je le sais. 
mais je cherche un exemple d'utilisation. Je n'ai pas trouvé grand chose.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...