Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1

    Default Javascript on 1 Document General page only

    Ok, I have added a flash video player to my site using the "Document General" category. The player and playlists work great.

    The problem is that I had to add some javascript to the "tpl_document_general_info_display.php" page and now the buttons for my playlists show up on ALL of my Document General pages. Is there some code I can add to the php page to make the javascript only show on one specific page? Possibly by the "id"?

    Here is the working page:
    http://www.thebasher.com/index.php?m...products_id=33

    And here is a link (one of many) to a page that I don't want the javascript to load on but as of now it does:
    http://www.thebasher.com/index.php?m...products_id=35

    I placed the code in the tpl_document_general_info_display.php to show up on the bottom of the page.

    If anyone has a fix I would greatly appreciate it.

    Thanks!

  2. #2

    Default Re: Javascript on 1 Document General page only

    Anyone have a suggestion or fix?

  3. #3
    Join Date
    Sep 2004
    Posts
    1,388
    Plugin Contributions
    4

    Default Re: Javascript on 1 Document General page only

    Unfortunately, due to the way templates are generated, you don't have many options in the realm of non-hack workarounds.

    The simplest solution would be to wrap the inclusion of your flash player in an if statement. The contents of the if statement would be the products_id values that match each product where the player should be displayed. Based on your posts, here's an example that assumes you only have the player on one product:
    Code:
    if ($_GET['products_id'] == 33) {
      // include your javascript here
    }
    Frank Koehl
    "Cleverly Disguised as a Responsible Adult"

    frankkoehl.com

  4. #4

    Default Re: Javascript on 1 Document General page only

    Hey Blindside. Thanks for the reply. I figured that I would need to include and "if" statement. However, it didn't work. Here is a snippet of the code where I put the "if" statement. I am possibly, and most likely, doing it wrong.

    Nice blog. The "Do Search Stats Dictate Your Agenda?" post was excellent. I couldn't agree more!

    [CODE]<!--bof Additional Product Images -->
    <?php
    /**
    * display the products additional images
    */
    require($template->get_template_dir('/tpl_modules_additional_images.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_additional_images.php'); ?>
    <!--eof Additional Product Images -->


    if ($_GET['products_id'] == 33) {
    <p align="center">
    <button onclick="javascript:createplayer('http://www.thebasher.com/mediaplayer/playlist_featured.xml', true)">Featured
    Videos<br />
    <img src="http://www.thebasher.com/mediaplayer/basher_tv/playlist_images/featured_video.jpg" alt="Featured Videos" width="100" height="100" /></button>

  5. #5

    Default Re: Javascript on 1 Document General page only

    For some reason I am not able to include all of the code so I made an attachment instead.
    java code.txt

  6. #6
    Join Date
    Sep 2004
    Posts
    1,388
    Plugin Contributions
    4

    Default Re: Javascript on 1 Document General page only

    I can't tell from your post or your attachment exactly what your code looks like (the attachment is full of backslashes and hex code). However, I am guessing that you're not closing the php tags before outputting your html. Here's a clearer example:
    Code:
    <!--bof Additional Product Images -->
    <?php
    /**
    * display the products additional images
    */
    require($template->get_template_dir('/tpl_modules_additional_images.php',DIR_WS_TEMPLATE , $current_page_base,'templates'). '/tpl_modules_additional_images.php'); ?>
    <!--eof Additional Product Images -->
    
    if ($_GET['products_id'] == 33) {
    ?>
    <p align="center">
    <button onclick="javascript:createplayer('http://www.thebasher.com/mediaplayer/playlist_featured.xml', true)">Featured Videos<br />
    <img src="http://www.thebasher.com/mediaplayer/basher_tv/playlist_images/featured_video.jpg" alt="Featured Videos" width="100" height="100" /></button>
    <?php
    // continue with php code...
    ?>
    Note the stuff highlighted in red.

    Thanks for the blog kudos!
    Frank Koehl
    "Cleverly Disguised as a Responsible Adult"

    frankkoehl.com

  7. #7

    Default Re: Javascript on 1 Document General page only

    I apologize for the text file. For some reason I'm having a bad night getting an example posted on the forum. (I've been tracking drums all night and tried to do it quick between takes)

    So I took a screen shot. Hopefully this works...

    Thanks for all of your help. I really appreciate it.
    Click image for larger version. 

Name:	code screenshot.jpg 
Views:	150 
Size:	84.5 KB 
ID:	3807

  8. #8
    Join Date
    Sep 2004
    Posts
    1,388
    Plugin Contributions
    4

    Default Re: Javascript on 1 Document General page only

    Yep, it's exactly what I thought. You need to jump out of PHP in order for the javascript to show up in the body of the page. Follow the highlighted instructions in my last message and you should get it working.
    Frank Koehl
    "Cleverly Disguised as a Responsible Adult"

    frankkoehl.com

  9. #9

    Default Re: Javascript on 1 Document General page only

    Ok, so I added the code but the buttons still show up on all of the Document General pages.

    Since I'm not the sharpest with php I'm thinking about customizing the "Document Product" category since I don't use that for anything else. That way the buttons for my video playlists will only show up on that one specific page.

    I do appreciate all of your help. Plus I found a new blog (subscribed to it today) to read.

    Thanks Blindside!

  10. #10
    Join Date
    Sep 2004
    Posts
    1,388
    Plugin Contributions
    4

    Default Re: Javascript on 1 Document General page only

    Your code is in as right a place as any, I wouldn't bother moving it. The logic is the problem. Try adding single quotes around the number in the if statement. Like this:
    Code:
    if ($_GET['products_id'] == '33') {
      // include your javascript here
    }
    Frank Koehl
    "Cleverly Disguised as a Responsible Adult"

    frankkoehl.com

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Wheres the file??? Document general page shows blank.
    By ben harry in forum General Questions
    Replies: 5
    Last Post: 14 Aug 2013, 02:47 PM
  2. Document General
    By ttmb33 in forum Customization from the Admin
    Replies: 1
    Last Post: 3 Feb 2011, 03:32 PM
  3. Product general in document general
    By Akasashasha in forum General Questions
    Replies: 7
    Last Post: 5 Apr 2010, 04:15 AM
  4. Document General
    By Astarkley in forum General Questions
    Replies: 9
    Last Post: 1 Sep 2009, 09:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg