7 Replies Latest reply: Feb 9, 2008 12:14 PM by jefbak RSS

    Can I use a php include to call a spry menu?

    jefbak Community Member
      Hi,
      How do I use a php include with spry? If menu.php in the following example contained a spry vertical menu with the .js and .css code:
      <?php include(' http://www.smith.edu/includes-nav/menu.php'); ?>

      Would I need to add the .js and .css files for spry in all the web pages or is there a way to add it to the include statement?
        • 1. Re: Can I use a php include to protect a spry menu?
          kevmartin Community Member
          I think you will have trouble protecting the css and js in this way. Anything in a php file that eventually renders down into html/css will be viewable as part of the source of the page in the browser. So you can then protect it with the old 'no-right-click' method, but view source will still work from browser menus. Even if you encrypt your files with ioncube, zend etc, the parts that render down into html/css are rendered by the browser before it displays it to the screen. You can't hide this type of source code as far as I know.
          • 2. Re: Can I use a php include to protect a spry menu?
            jefbak Community Member
            I just need to keep the spry menu.php in a read only directory so others can't change the menu. We use this include method for several navigation areas on our pages, but this is the first time to try and use spry that way.

            I guess I am going to have to include the js and css file references in all pages and not just the menu.php page that gets called by the php include.

            The problem is that dreamweaver thinks the spry widget is missing every time I open a page to edit and asks me if I want to delete the spry related code.


            does this make sense?
            • 3. Re: Can I use a php include to call a spry menu?
              MikeL7 Community Member
              I have made a spry menu in a php include page, what you want to do is make a blank php page with no doc type declaration. Totally blank in code view, then put the code for your menu in the page, with the script tags, there are three i think the script tag in the head, the css file in the head, and the script tag at the bottom.
              So there is nothing but,

              script source=spryvert.js
              css=spryvert.css
              html code
              script spry widget

              Then include the page on your pages with a php require(menu.php)
              with the quotes around the page of course.
              • 4. Re: Can I use a php include to call a spry menu?
                jalperin Community Member
                I just tried this and it works very well with one remaining quirk. On the main page, Dreamweaver renders the Spry menu as an unordered list (i.e. with bullets) instead of using the appropriate menu styling. The page itself renders just fine in the browser, but the Design view of Dreamweaver isn't working for that element. When I look at the menu page (the one that is being included) within Dreamweaver, it renders just fine in Design view. Is there a way to fix this?
                • 5. Can I use a php include to call a spry menu?
                  jefbak Community Member
                  I had just found a similar answer in a book I have here: Friendsof, The Essential Guide To Dreamweaver CS3, with CSS, Ajax and PHP

                  Great book. Just copy over the xhtml and Spry object init script (var's at the bottom of the page) to the php include file and nothing else. Not the CSS of JS files (more on why below).

                  One thing, in the Advanced View of Site Manager in Dreamweaver, you need to indicate where the Spry folder is. This will fix the design view for the page doing the include.

                  The spry js and css links stay in the page running the include.

                  The problem with pasting all the css and js Spry related code into the page (according to this book) is that you will end up with the link to the external style sheet within the <body> tags of the document calling the include file.

                  Then the menu shows up in design view.
                  Design time can be used to add the css to the menu.inc.php file.


                  But know that I figured all this out I still can't use a PHP include for this menu. My other problem is that the menu item from the include file must be "HOT" when the page the menu item relates too is open. So it has a different css style applied. Well this work if it is a php include?
                  • 6. Re: Can I use a php include to call a spry menu?
                    MikeL7 Community Member
                    You only want the code for the link to the css and js file the html code for the list, and the script tag at the bottom of the page in your include page. The menu will remain editable in design view if you use the php include where it needs to be.
                    • 7. Re: Can I use a php include to call a spry menu?
                      jefbak Community Member
                      See I am being told no CSS link and no JS link in the include file, just the html and var setting.

                      Because then the css will be called within the Body tags. Some browsers can deal with this and some can't. And as browsers get more standards compliant having this in the Body will cause problems down the line.

                      This is only if your include is within the Body tags of course (which most are).

                      Anybody have any ideas how to determine if the spry vertical menu item should be "hot" (look different then the other menu items for the page of the menu item) if it is called from php include?

                      I am trying to use a template instead now, because I can manually change the Hot class for each page, but I would rather use the include if I can...