Jump to content

[solved] How to modify getCMSLink for lightbox as content_only?


janthemanson

Recommended Posts

Hey there!

 

I want to expand the conditions section of the OPC with and aditional CMS Link.

 

The behaviour of the conditions link is that it opens in lightbox as "content-only" display.

I wanted the link to be dynamic, so I used $link->getCMSLink('id'). It opens in lightbox, but as full page.

How can I achive that only the content of the cms-page opens?

I know that I can use '?content_only=1', but what I don't know is where I can implement this.

 

Thanks in advance, Jan

 

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

  • 3 months later...

Maybe you can use this ?

 

// File: product.tpl
// Line: 225 (depends on desired location)
// This code will display a translatable link that will display a fancybox popup.
// The content for this fancybox is a CMS page that is displayed as content-only.
// Change the CMS ID with the correct cms page.
// Change the width&height of the fancybox with javascript and the size of the cms page.
 
<!-- 108Bits -->
    {if !$logged}
     <p><a href="{$link->getCMSLink('8')}?content_only=1" class="iframe" rel="nofollow">
     {l s='Shipping Terms'}</a></p>
    {/if}
<!-- END 108Bits -->
 
// Add this at the end of the file (after {/if} )
<script type="text/javascript">
    $('a.iframe').fancybox({
        'type' : 'iframe',
        'width':500,
        'height':900
    });
</script>
  • Thanks 1
Link to comment
Share on other sites

Hey uddhava,

 

thank you for your support! The {if !$logged} breaks actually the link. I've tried it without and so the generation of the link works.

 

 

Another Problem: I'm using partial SSL mode, so without https the link won't load it's contents into the lightbox and the actual cmsLink is missing the https.

 

 

The javascript I think is obsolete, cause lightbox is already defined somewhere in the theme.

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

it's worth to mention that this will work only with friendly urls.

if you will use prestashop without friendly urls you will have two question marks in url - and it's bad, all other variables after second question mark will not work

Link to comment
Share on other sites

it's worth to mention that this will work only with friendly urls.

if you will use prestashop without friendly urls you will have two question marks in url - and it's bad, all other variables after second question mark will not work

 

Ok, I forgot to make that clear. Thank you for your hint!

 

We use friendly urls since the bug with php cgi is fixed and don't want to step back. We need the better SEO performance.

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

@ janthemanson

 

The {if $logged} is used to show the link only when people are not logged in. This was a question of a customer of mine.

 

So the code should be : (works ONLY with Friendly URLS)

 

// File: product.tpl
// Line: 225 (depends on desired location)
// This code will display a translatable link that will display a fancybox popup.
// The content for this fancybox is a CMS page that is displayed as content-only.
// Change the CMS ID with the correct cms page.
// Change 'rewrite' with the actual friendly url of your cms page
// true : if you use SSL
// Change the width&height of the fancybox with javascript and the size of the cms page.
 
     <p><a href="{$link->getCMSLink('8','rewrite',true)}?content_only=1" class="iframe" rel="nofollow">
     {l s='Shipping Terms'}</a></p>
 
// Add this at the end of the file (after {/if} )
<script type="text/javascript">
    $('a.iframe').fancybox({
        'type' : 'iframe',
        'width':500,
        'height':900
    });
</script>
 
I was wondering if this would be possible to use WITHOUT friendly urls. Is there a smarty variable we can check?
Edited by uddhava (see edit history)
Link to comment
Share on other sites

@uddhava

 

Hey thank you very much.

I've tried to implement "?content_only=1" several times before, but with no luck!

I pasted it within the brackets, so this didn't worked out.

 

The working solution for me is only the link code like this:

<a href="{$link->getCMSLink('8','rewrite',true)}?content_only=1" class="iframe" rel="nofollow">{l s='Shipping Terms'}</a>

As I said it before I used this in the conditions section of the OPC (OnePageCheckout) so the file is order_carrier.tpl.

 

Cause we use a well packaged theme (not the default), the javascript code is obsolete.

The lightbox is already defined and of course responsive, so I need no extra width and height properties, it already loads without it.

 

This maybe helpful for people who try to implement this on other pages or in other themes.

Link to comment
Share on other sites

  • 2 years later...

Hi everyone!  :) 
 
I am trying to show a CMS as a popup when someone clicks on the native banner module.
 
I was able to show the CMS thanks to that link: http://www.alexandre-rabottin.fr/blog/comment-afficher-des-pages-en-popup-sur-prestashop-1-4-et-1-5/ (in French).
 
BUT (there is always a but!), the popup shows with the page's header and footer.  :unsure: 
 
I am not able to figure out where to enter the

?content_only=1 

 
Here is the code in banner.tpl. I added the class="iframe" but not the content_only=1 because I do not know where to put it.

<a class="iframe" href="{if $banner_link}{$banner_link|escape:'htmlall':'UTF-8'}{else}{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}{/if}" title="{$banner_desc|escape:'htmlall':'UTF-8'}">
{if isset($banner_img)}
<img class="img-responsive" src="{$banner_img|escape:'htmlall':'UTF-8'}" alt="{$banner_desc|escape:'htmlall':'UTF-8'}" title="{$banner_desc|escape:'htmlall':'UTF-8'}" width="1170" height="65" />
{else}
{$banner_desc|escape:'htmlall':'UTF-8'}
{/if}
</a>

Where and what do I have to do please so that only the content of the CMS page shows?

 

Thanks a lot for your help!  :D

 

I am on PS 1.6.1.6.

Link to comment
Share on other sites

Ok so by writing the problem to you, some things got clear in my head and I found my solution. Here it is:

The code is correct. The only place where I have to add the content_only=1 is the actual URL in the banner module.

 

So open your banner module. In the link, enter the URL to your CMS followed by the content_only=1 call. Like this: /url-of-your-cms?content_only=1

 

I hope it helps someone! :)

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...