Announcement

Collapse
No announcement yet.

Custom page template calls another template issue

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom page template calls another template issue

    Hi, I hope someone can help me. I'm using Genesis/Dynamik. I have some custom page templates I'm moving over from another older website which did not use Genesis/Dynamik. I got one of the page templates to work fine by creating a new custom page template in Dynamik, and pasting in the code. Then selecting that template for the new page I created.

    I'm having a problem with the other one.

    I have a custom page template named "previous years listing" which calls upon another custom page template named "previous years listing javascript" to be displayed. If I select the template "previous years listing" it displays a page that looks ok with a header, nav and footers, except for there is no content from "previous years listing javascript".

    If I select the template "previous years listing javascript", that content displays ok, except for then the page header, nav and footers are missing.

    So I think both parts are working ok separately, I just can't get them to work together. Help?

    Here is the code in question:

    <?php
    /*
    Template Name: Previous Years Listing
    */
    ?>

    <?php get_header(); ?>

    <div id="content">
    <div id="news_line"/>

    <?php include( TEMPLATEPATH . '/previous_years_listing_javascript.php'); ?>
    <div id="stage_tab_content"><br></div>
    <div id="tab_content_bottom"></div>
    </div>

    <?php get_footer(); ?>


  • #2
    I've made some progress on this. I ended up putting the script for 'previous_years_listing_javascript' in the the 'previous_years_listing' template.

    This is what it looks like: http://cincyblues.org/bluesfest_3/pr...years-line-up/

    Now the problem is it's supposed to show a festival lineup for each year when you select it from the pull down menu and click the button on the right. That is not working.

    Here is how it worked on the old site: http://www.cincybluesfest.org/previous-years-line-up/

    I tried making a custom template for one of the years in Dynamik to test it, but that didn't work. There is a page template for each year in the My Templates folder.

    I think I'm running into the same TEMPLATEPATH issue which doesn't seem to work with Dynamik. I've tried get_template code, and I think I got it right, but it didn't work. I'm don't know enough about code to know what is wrong. Just about enough to be dangerous :-)

    Here is what the template looks like now - help?

    <?php
    /*
    Template Name: Previous Years Listing
    */
    ?>

    <?php get_header(); ?>

    <div id="content">
    <div id="news_line"/>

    <script'>

    <!--
    function forwardToSelectedLineup()
    {

    var previouYearsLineup = document.getElementById("selectedLineup");
    var length = previouYearsLineup .options.length;
    for (var i = 0; i < length; i++)
    {
    if( previouYearsLineup .options[i].selected )
    {
    window.location = previouYearsLineup .options[i].value;
    break;
    }
    }
    }

    function setSelectedLineup( selectedLineup)
    {

    var previouYearsLineup = document.getElementById("selectedLineup");
    var length = previouYearsLineup .options.length;
    for (var i = 0; i < length; i++)
    {
    if( previouYearsLineup .options[i].selected )
    {
    previouYearsLineup .options[i].selected = false;
    break;
    }
    }
    for (var i = 0; i < length; i++)
    {
    if( previouYearsLineup .options[i].value == selectedLineup )
    {
    previouYearsLineup .options[i].selected = true;
    break;
    }
    }
    }
    -->
    </script>

    <?php


    function findPreviousLineupPage()
    {
    $categoryNameToInclude = 'previous line-up';
    $previouLineupPages= array();
    $getPageArguments = array( 'sort_order' => 'DESC',
    'sort_column' => 'menu_order',
    'post_type' => 'page',
    'post_status' => 'publish'
    );
    $pages = get_pages( $getPageArguments );
    $category_id = get_cat_ID( $categoryNameToInclude );
    foreach ($pages as $page)
    {
    $categories = get_the_category($page->ID);
    if( $categories )
    {
    foreach( $categories as $category )
    {
    $categoryName = $category->cat_name;

    if ( $categoryName == $categoryNameToInclude )
    {
    $previouLineupPages[] = $page;
    }
    }
    }
    }
    return $previouLineupPages;
    }

    $previousLineupPageArray = findPreviousLineupPage();
    ?>

    <div id="schedule_menu">
    <div class="schedule_tab">
    Select the year, then click the button on the right to view the line-up.
    </div>
    </div>

    <div id="stage_schedule_times">
    <table>
    <tr>
    <td>
    <select id="selectedLineup" style="height:40px; background-color:Chocolate;" >
    <?php
    foreach ($previousLineupPageArray as $page)
    { ?>
    <option value="<?php echo get_permalink( $page->ID); ?>"><?php echo $page->post_title; ?></option>
    <?php }?>
    </select>
    </td>
    <td>
    <button type="button" onclick= "forwardToSelectedLineup()"
    style="width:300px;height:40px; background-color:Chocolate;font-weight: bold; " >Click Here</button>
    </td>
    </tr>
    </table>
    </div>
    <br/>
    <br/>

    <div id="stage_tab_content"><br></div>
    <div id="tab_content_bottom"></div>
    </div>

    <?php get_footer(); ?>

    Comment


    • #3
      Last call - anybody? Help?

      Comment


      • SiGa
        SiGa commented
        Editing a comment
        I fear this might be too far into customization to contact support staff, but also I don´t really see how we could handle this from frontend here in forum. If you think the template path might be the problem, I´d try support anyway. If this doesn´t work, you might want to hire one of the third party devs to solve this specific problem for you. https://cobaltapps.com/developers/

      • chiselpoint
        chiselpoint commented
        Editing a comment
        Thanks for the list of developers.

    • #4
      Well , Xmas , new year holiday period ... gonna be hard to get many replies , but anyway ... i had a quick look and the link to your new site throws some errors related to that

      Code:
      Uncaught ReferenceError: forwardToSelectedLineup is not defined(…)
      Uncaught SyntaxError: Unexpected token < - custom-scripts.js?ver=1.7.1:1
      Looking at the code you posted above -

      Check this bit >>

      Code:
      <div id="content">
      <div id="news_line"/>
      
      <script'>
      where you see <script> notice you have an unwanted ' remove that as it's bringing the whole shebang to a grinding halt. Beyond that quick look , can't help much more

      Comment


      • chiselpoint
        chiselpoint commented
        Editing a comment
        Removing the quote from the script tag made it work a bit better. Thanks.

      • andytc
        andytc commented
        Editing a comment
        That's great , your making some progress. Let us know how it goes.

    • #5
      Well, I had all but given up and accidentally stumbled onto something that made it work. All I needed to do was make a new page for 2016, and tell it what template to use. Then for the other older pages, all I needed to do was re-Publish them. Apparently, the system didn't know they were in the my-templates folder until then.

      So this is what I have now. http://cincyblues.org/bluesfest_3/pr...ars-line-up-2/

      The sidebar is showing up which is good.

      Now what I need is to have content from the page show up, and then also breadcrumbs. That would be on both the Previous Years Lineup page and each individual Year page. Any ideas?

      So for example, this is the content from the page for 1992 (see screen shot). Then you can see it's not showing up on this page - http://cincyblues.org/bluesfest_3/1992-line-up/

      Here is the code:

      text/x-generic previousSchedule1992.php
      PHP script text
      <?php
      /*
      Template Name: Previous Schedule 1992
      */
      ?>

      <?php get_header(); ?>
      <?php get_sidebar(); ?>
      <div id="content">
      <div id="news_line"/>
      <?php include (TEMPLATEPATH . '/BreadCrumbFunction.php'); ?>

      <?php include (TEMPLATEPATH . '/socialMediaButtons.php'); ?>
      <?php include (TEMPLATEPATH . '/displayPostTitlePostMessage.php'); ?>

      <?php include( TEMPLATEPATH . '/previous_years_listing_javascript.php'); ?>


      <div id="schedule_menu">
      <div class="schedule_tab">
      Saturday 1992
      </div>
      </div>

      <div id="stage_tab_content">
      <div id="stage_schedule_heading">
      <br />
      (1992) Budweiser Main Stage (1992)
      </div>

      <div id="stage_schedule_times">
      <?php $saturdaytimes_args = array(
      'post_type' => 'mainstage',
      'order' => 'ASC',
      'orderby' => 'meta_value_num',
      'meta_key' => 'sort_order',
      'category_name' => '1992_Saturday',
      'posts_per_page' => 10 );
      $saturdaytimes_loop = new WP_Query( $saturdaytimes_args );
      while ( $saturdaytimes_loop->have_posts() ) : $saturdaytimes_loop->the_post(); ?>
      <li><a href="<?php the_permalink(); ?>"><?php echo get_post_meta($post->ID, time_slot, true); ?></a></li>
      <?php endwhile; ?>
      <?php wp_reset_query(); ?>
      </div>

      <div id="stage_schedule_content">
      <?php $saturday_args = array(
      'post_type' => 'mainstage',
      'order' => 'ASC',
      'orderby' => 'meta_value_num',
      'meta_key' => 'sort_order',
      'category_name' => '1992_Saturday',
      'posts_per_page' => 10 );
      $saturday_loop = new WP_Query( $saturday_args );
      while ( $saturday_loop->have_posts() ) : $saturday_loop->the_post(); ?>
      <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
      <?php endwhile; ?>
      <?php wp_reset_query(); ?>
      </div>


      </div>

      <div id="tab_content_bottom"></div>
      </div>
      <?php include (TEMPLATEPATH . '/spon.php'); ?>
      <?php get_footer(); ?>
      Attached Files
      Last edited by chiselpoint; 01-09-2017, 07:52 PM. Reason: code not showing up right.

      Comment


      • #6
        You might want to get into Genesis templating, seeing Genesis is the parent theme. That way, you can write less code and let Genesis do its thing the Genesis way, following the settings in Genesis - Theme Settings also. Genesis will call all page elements - including breadcrumbs and sidebars when they´re set - itself. No need to write it out.
        Here´s a basic article to start with: https://cobaltapps.com/custom-page-t...e-dynamik-way/
        Also: http://yivva.com/create-custom-page-template-genesis/

        Sometimes it´s easier to just remove unwanted elements (instead of listing all the default ones) or just replace the default loop with the custom loop from the older templates (or add one in addition to the content like in this example).
        https://carriedils.com/custom-page-template-genesis/

        You´ll find lots of helpful articles out there if you just start your searches with "genesis .... (custom template)"
        Also note the code snippets on the StudioPress site (to remove/add elements, change/edit elements, force layouts and more).
        Last edited by SiGa; 01-09-2017, 08:43 PM.

        Comment

        Working...
        X