No announcement yet.

is it possible to hide pages/sections from unregistered users?

  • Filter
  • Time
  • Show
Clear All
new posts

  • is it possible to hide pages/sections from unregistered users?

    I was wanting to hide certain headers, footers, or site pages I create from unregistered users. Is there a code i can insert to accomplish this?

  • #2
    Yes, but it will require some use of javascript on your end.

    In the frame.html there is a seciond called <!--START: username-->
    This block is only executed if the current user is logged in.

    You can set a JS variable there, like:

    <script type="text/javascript">
    var isLoggedIn = 1;

    And then elsewhere on your page check that variable and hide/show sections as needed.


    • #3
      Thank you , i appreciate your help, I tried doing it, but I was only able to get the search box to dissapear and not reappear when i'ts logged in.

      The original code is here below, what would i change this to.

      <!--START: FRAME_SEARCH-->
      <div><img src="assets/templates/common/images/spacer.gif" width="1" height="5"></div>
      <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" ID="Table2">
      <form method="get" name="searchForm" action="search.asp" STYLE="margin: 0px; padding: 0px;" ID="Form1">
      <td><input type="text" size="20" name="keyword" id="searchlight" class="txtBoxStyle" onFocus="javascript:if (document.searchForm.keyword.value=='search by keyword') {document.searchForm.keyword.value='';};" onBlur="if(this.value.length == 0) this.value = 'search by keyword'" value="search by keyword"></td>
      <td><input type="submit" name="search" value="GO" class="btn" onMouseOver="this.className='btn_over'" onMouseOut="this.className='btn'" ID="Submit1"></td>
      <div><img src="assets/templates/common/images/spacer.gif" width="1" height="5"></div>
      <!--END: FRAME_SEARCH-->


      • #4
        There are a ton of ways to implement this. I guess the way I would do it is to put this script inside the <!--start: username--> block:

        <script type="text/javascript">
        	$(document).ready(function() {
        then change the form to:

        <form method="get" name="searchForm" action="search.asp" STYLE="margin: 0px; padding: 0px; display:none" ID="Form1">
        (The addition is in bold font)

        What this does is makes the <form> hidden by default, and then a javascript loads only when the user is logged in which will show it. It relies on JQuery, which I think most templates have installed but maybe not all. If this gives you errors let me know..


        • #5
          Hi, thank you. How many times can i have <!--START: username--> put in the template. I inserted the original frame search script in between the existing <!--START: username--> and END username blocks, it worked perfect. but only problem was the location of the search script was not where i want it. I tried adding the start and end username blocks a 2nd time on the frame.html and it didn't work for the second time.


          • #6
            You can only have it once. It is only to contain the logged in users name and links to their account page. You can stash some javascript in there, as I have done.
            So the javascript will only activate when the user is logged in, and that will in turn display the Search Form, which is in its normal place in the template.


            • #7
              Is there any way to do this so the content (in my case, a certain div) only shows for a certain user group when logged in?
              Red Peach Designs


              • #8
                Sort of. You can combine the technique about with the [price_level] variable to find out what the user's discount level is. If the discount level is unique to a customer group, then you're golden.