ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Hidden Templates and jQuery

March 23, 2012 10:28am

Subscribe [3]
  • #1 / Mar 23, 2012 10:28am

    PaulAyling

    16 posts

    Hi I’ve just created a set of templates Overview and detail and am using jQuery to load one into the other, but I need to hide the templates detail template from browser view, I’ve tried adding the .templatename no joy gives me a 404 using jQuery .load .

    So question is, is there another way to hide templates?

    Thanks

    Paul

  • #2 / Mar 25, 2012 8:13am

    Sean C. Smith

    3818 posts

    Hi PaulAyling,

    If you hide the template using the .templatename method you will not be able to load it via jquery since it’s not available by accessing the template name. Could you post up your template code with some more detail of what you are trying to achieve and what is or is not working for you.

    Sean

  • #3 / Mar 26, 2012 8:19am

    PaulAyling

    16 posts

    Thanks for coming back to me, I’ve found a work around 😊


    Loading a template via $(#‘newsList’).load(/templateName/); etc

    I dont want the loaded template accessed directly so added the following to the top of the template to be loaded.

    <?php
     if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) != 'XMLHttpRequest' ) { ?>
    
      {redirect='news/<?php echo $newsYear; ?>'}
     <?php
      } else {
     ?>
    
    tempate details
    
    <?php 
             } 
    ?>

    Is there a EE native way of doing it ?

     

     

  • #4 / Mar 28, 2012 6:03pm

    Dan Decker

    7338 posts

    Hi Paul,

    I gather you have a specific need to load these template via AJAX?

    You can use the ExpressionEngine constant AJAX_REQUEST in place of your PHP check:

    {if AJAX_REQUEST == FALSE}
     {redirect='news/<?php echo $newsYear; ?>'}
    {/if}
    template details

    Let me know if that works for you!

    Cheers,

  • #5 / May 29, 2012 8:30am

    PaulAyling

    16 posts

    Sorry really didnt mean to leave this hanging, got caught up getting sites ported. Afraid that didnt work, show the correct out put if not loaded via ajax, but incorrect when loaded via ajax.

    Thanks anyway and again sorry for leaving this so long

  • #6 / May 31, 2012 1:38pm

    Shane Eckert

    7174 posts

    Hey PaulAyling,

    No worries at all!

    Where are things now? Do you still need support?

    Cheers,

  • #7 / Jun 01, 2012 2:05am

    PaulAyling

    16 posts

    Not on this on 😊 please close

    Cheers
    Paul

  • #8 / Jun 01, 2012 6:01pm

    Shane Eckert

    7174 posts

    Hey PaulAyling,

    Closing the thread out!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases