Post by robster » Sun Oct 17, 2010 11:47 pm

I have had a pretty good look around the forum but can't find what I am looking for:

Is there a way (or indeed a mod) that will allow me to create CMS pages but only have them visable to customers when they are logged in"

Cheers

robster

I know my place...!


User avatar
Active Member

Posts

Joined
Tue Jul 13, 2010 8:08 pm
Location - North Yorkshire, UK

Post by jones » Mon Oct 18, 2010 1:46 am

I just try to help you out...

try this:

1. open catalog folder:

controller/common/home.php

find:

Code: Select all

                $this->data['text_latest'] = $this->language->get('text_latest'); 
add after:

Code: Select all

        
        $this->data['logged'] = $this->customer->isLogged(); // New Addition
         
2. open catalog\view\theme\YOUR_LOVE_TEMPLATE\template\common\home.tpl

find:

Code: Select all

  <div class="top">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center">
      <h1><?php echo $heading_title; ?></h1>
    </div>
  </div>
  <div class="middle">
    <div><?php echo $welcome; ?></div>
  </div>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div>
Replace with:

Code: Select all

  <div class="top"><?php if ($logged) { ?>
    <div class="left"></div>
    <div class="right"></div>
    <div class="center">
      <h1><?php echo $heading_title; ?></h1>
    </div>
  </div>
  <div class="middle">
    <div><?php echo $welcome; ?></div>
  </div>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div><?php } ?>
3. then go to admin area: System-->Store then fill the welcome message with your news/announcement to your logged customers

Active Member

Posts

Joined
Tue Aug 24, 2010 1:05 pm

Post by robster » Mon Oct 18, 2010 3:19 am

Hi jones and thanks for taking the time to help.

Does your solution just work on home page? I really need it to work on specific pages that I create in admin. Like page id5 or page id8, etc if you understand me..... :)

robster

I know my place...!


User avatar
Active Member

Posts

Joined
Tue Jul 13, 2010 8:08 pm
Location - North Yorkshire, UK

Post by Johnathan » Mon Oct 18, 2010 7:17 am

It's not the most elegant solution, but you can use the following to change the content of an information page based on its SEO keyword URL:

IN:

Code: Select all

/catalog/view/theme/YOURTHEME/template/information/information.tpl
BEFORE THE CONDITIONAL CONTENT ADD:

Code: Select all

<?php if($_SERVER['REQUEST_URI'] == '/myinfopage') { ?>
AND AFTER THE CONDITIONAL CONTENT ADD:

Code: Select all

<?php } ?>
The REQUEST_URI is the part of the URL that comes after the domain name (e.g. http://www.mysite.com). In the example, I used the SEO keyword of "myinfopage". If you combined this with the "if logged in" part it would be:

Code: Select all

<?php if ($this->customer->isLogged()) { ?>
    <?php if($_SERVER['REQUEST_URI'] == '/myinfopage') { ?>
        HTML content here
    <?php } elseif($_SERVER['REQUEST_URI'] == '/anotherpage') { ?>
        Different HTML content here
    <?php } ?>
<?php } else { ?>
    Content to show if customer isn't logged in
<?php } ?>
I have tried this code, but it should work for you.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by jones » Mon Oct 18, 2010 11:42 am

robster wrote:Hi jones and thanks for taking the time to help.

Does your solution just work on home page? I really need it to work on specific pages that I create in admin. Like page id5 or page id8, etc if you understand me..... :)

robster
hi robster,

i just noted your 1st message
"but only have them visable to customers when they are logged in"
but now it more clear to me.

then if you want
work on specific pages that I create in admin. Like page id5 or page id8
as similar to Jonathan suggested

you also can create in /catalog/view/theme/YOURTHEME/template/information/information.tpl your conditional content by detected the URL id e.g. index.php?route=information/information&information_id=5

if not someone can create this module for you maybe just $12 USD

Active Member

Posts

Joined
Tue Aug 24, 2010 1:05 pm

Post by hampo1989 » Fri Jun 17, 2011 10:44 pm

Hi is there a way to do this, but by customer group!?

For example someone part of a wholesale group can see a page,
And all other customers (default) cant.

Thanks
Andy

Newbie

Posts

Joined
Tue Jul 20, 2010 2:44 am

Post by SXGuy » Sat Jun 18, 2011 7:32 pm

yes you can do the same for customer group, but you need to know the customer group id value relative to the group name.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by hampo1989 » Mon Jun 20, 2011 5:30 am

How would i put that into code?

Lets say for example on a product page i want to display "hello wholesale" to the wholesale customers (id 1) and
"hello default customer" to the default customer groups (id 2)

Thanks
Andy

Newbie

Posts

Joined
Tue Jul 20, 2010 2:44 am

Post by teclive » Sat Jan 26, 2013 12:43 am

Hi there everyone, hope we are all doing well.
I know its been awhile since someone has posted to this thread, so hopefully folks are still reading it.

I read the solution from Johnathan, by the way, i have purchased a few of your modules, and they all work great. Thank you.

I would like to do the same thing as mentioned in this thread title, I would like to hide a certain page. If customer is logged in, then they can view it, if they are not logged in, they get redirected to the login/register page

Kicker is, i would like to do this on a CMS module that I purchased, however, the developer seems to have fallen off the face of the earth.

I have attached a txt file of the code that is in the file that i think I need to edit.
On the server the path to this tpl file is catalog/view/theme/THEMENAME/template/news/article.tpl

Would the same idea as mentioned earlier in this post work with this file? if so, where abouts would I put the code?

thanks in advance for your help, much appreciated

T

New member

Posts

Joined
Fri Jul 09, 2010 2:29 am

Post by andyblackett » Thu Jul 25, 2013 5:16 am

jones wrote:I just try to help you out...

try this:

1. open catalog folder:

controller/common/home.php

find:

Code: Select all

                $this->data['text_latest'] = $this->language->get('text_latest'); 
add after:

Code: Select all

        
        $this->data['logged'] = $this->customer->isLogged(); // New Addition
 
2. open catalog\view\theme\YOUR_LOVE_TEMPLATE\template\common\home.tpl

find:

Code: Select all

  <div class="top">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center">
      <h1><?php echo $heading_title; ?></h1>
    </div>
  </div>
  <div class="middle">
    <div><?php echo $welcome; ?></div>
  </div>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div>
Replace with:

Code: Select all

  <div class="top"><?php if ($logged) { ?>
    <div class="left"></div>
    <div class="right"></div>
    <div class="center">
      <h1><?php echo $heading_title; ?></h1>
    </div>
  </div>
  <div class="middle">
    <div><?php echo $welcome; ?></div>
  </div>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div><?php } ?>
3. then go to admin area: System-->Store then fill the welcome message with your news/announcement to your logged customers
I used your suggestion above to hide the category description if the user is not logged in and it worked perfectly - thankyou so much!

Andy

Newbie

Posts

Joined
Mon Dec 31, 2012 7:54 am
Who is online

Users browsing this forum: No registered users and 19 guests