daniel churchill
daniel churchill

Reputation: 43

Prestashop content only link not working

I've got the terms and conditions link and added Fancybox to it, however it comes up with the entire web page, not just the content in the fancy box container when you click the link.

The link is in the format site/online-store/au/content/3-terms-and-conditions-of-use?content_only=1

however the content_only=1 doesn't appear to do anything?

Upvotes: 1

Views: 5016

Answers (3)

Bruno Leveque
Bruno Leveque

Reputation: 2811

This will work for PrestaShop 1.6.x/1.7.x and will open the ToS in a Fancybox

In your controller:

$cms = new CMS(Configuration::get('PS_CONDITIONS_CMS_ID'), $this->context->language->id);
$conditions_link = $this->context->link->getCMSLink($cms, $cms->link_rewrite).'?content_only=1';
$this->addJqueryPlugin(array('fancybox'));
$this->context->smarty->assign(['conditions_link' => $conditions_link]);

Then, in your .tpl file:

<a class="fancybox-tos" href="{$conditions_link}">{l s='Terms of service' d='Shop.Theme.Checkout'}</a>

And finally, in your .js file:

$(document).ready(function() {
        $('.fancybox-tos').fancybox({
            type: 'iframe',
            autoDimensions: false,
            autoSize: false,
            width: 600,
            height: 'auto',
            helpers: {
                overlay: {
                locked: false
            }
        }
    });
});

I hope this helps!

Upvotes: 0

devst3r
devst3r

Reputation: 562

The issue is because the CMS you load doesn't have the required parameters. Thus, the condition in

/controllers/front/CmsController.php

if (Configuration::get('PS_SSL_ENABLED') && Tools::getValue('content_only') && $id_cms && Validate::isLoadedObject($this->cms) && in_array($id_cms, array((int)Configuration::get('PS_CONDITIONS_CMS_ID'), (int)Configuration::get('LEGAL_CMS_ID_REVOCATION')))) 
{
  $this->ssl = true;
}

Returns false. just replace this with

 $this->ssl = true;

Tada...

Upvotes: 0

Jordi
Jordi

Reputation: 3673

The problem is that this link is loading a non-https content from an https page.

To fix it, edit controllers/front/ParentOrderController.php

$this->link_conditions = $this->context->link->getCMSLink($cms, $cms->link_rewrite, false);

and change last parameter to true to force the use of https

$this->link_conditions = $this->context->link->getCMSLink($cms, $cms->link_rewrite, true);

Upvotes: 2

Related Questions