Welcome to TalkGraphics.com
Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1

    Default Adding code to start and end of file

    Hello,

    I have XWD5 and have a page that needs some code inserting on the top line and bottom line of the html file that XWD generates. Placeholders cant be used as they will be within the html tags, any idea how i can do it?

    Currently every time i amend the site and re-export the site ive got to copy and paste the code to the top n bottom to test it.

    thanks

  2. #2
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,044

    Default Re: Adding code to start and end of file

    The tracker code under web properties will sort out the bottom half. where do you need the code for the top ? <head> or <body>.

  3. #3
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: Adding code to start and end of file

    What is the purpose of placing code at the very end of the file?
    John.

  4. #4

    Default Re: Adding code to start and end of file

    Hiya,

    Thanks for the feedback. My problem is that the file it generates is a PHP file which contains a logon system requiring the use of the php location header function to redirect a logged on user. When you use this function it has to be the first thing called on the page or it wont work. So a pure PHP page will work fine with it in the right place but when you have HTML above the php code it wont work.

    Using XWD and place-holders combined with php buffers i have got the page to look great and work. In order for it to work though the page must have:

    <? php
    ob_start();
    ?>

    At the top three lines of the file before <html>. And then this at the bottom of the file after </html>:

    <? php
    ob_end_flush();
    ?>

    Hope this makes sense?

    Thanks

  5. #5
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: Adding code to start and end of file

    No it doesn't answer my question. What does the bottom part do? Why is it restricted to be placed after all the HTML code? And is it?
    The top part can be easily added in WD6.
    John.

  6. #6
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,044

    Default Re: Adding code to start and end of file

    It might be easier to work the other way around. include the .htm file within an index.php file

    <? php
    ob_start();
    ?>

    <!--#include virtual="index.htm" -->

    <? php
    ob_end_flush();
    ?>

  7. #7

    Default Re: Adding code to start and end of file

    Quote Originally Posted by covoxer View Post
    No it doesn't answer my question. What does the bottom part do? Why is it restricted to be placed after all the HTML code? And is it?
    The top part can be easily added in WD6.
    Hi,

    I have a php file that works fine as it is but is simply page with a black background and a logon box asking for a username and password. There is a loop on the page so when a successful logon occurrs it uses this function.

    http://www.w3schools.com/php/func_http_header.asp

    I am trying to make the site look "nice" by creating a layout in XWD and putting the php code in placeholders on various objects i draw like a rectangle. This way I can make a nice looking page with a logon box integrated into the page if that makes sense. In the background the php handles the logon system.

    As soon as I used this method with the logon box, because it uses the header function it doesnt work and never logs a user on. Apparently this is because it needs to be above any further code on the page which the loop currently does which that link explains.

    After hunting around php forums I found someone else with a similar issue used the ob start and end flush to create a buffer and effectively make a sandwich of code like this:

    php buffer
    html to look nice
    php logon code
    html footer
    php buffer end

    by making it all within a php file it works fine with the downside of having to add that code to the top and bottom of the page every time i want to use it.

    Does this explain it a bit better?

    Thanks

  8. #8

    Default Re: Adding code to start and end of file

    Quote Originally Posted by Drwyd View Post
    It might be easier to work the other way around. include the .htm file within an index.php file

    <? php
    ob_start();
    ?>

    <!--#include virtual="index.htm" -->

    <? php
    ob_end_flush();
    ?>
    That looks like a good idea, I dont know if it will work but I can certainly try it out. That way I can leave the HTML editing for XWD and keep the code working possibly.

    Cheers

  9. #9
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: Adding code to start and end of file

    You are still explaining about the code for the beginning, and I'm asking about the ending code.
    The code at the beginning is frequently requested feature and it is added in XWD6. But the code at the end of the HTML is something new to me. This was never requested yet and I do not see obvious reasons for this to be mandatory. I suspect that the same code you add at the end would work just as well being inserted in the tracker field. In case it's not, I have to know more about the problem thus the question.
    John.

  10. #10

    Default Re: Adding code to start and end of file

    Quote Originally Posted by covoxer View Post
    You are still explaining about the code for the beginning, and I'm asking about the ending code.
    The code at the beginning is frequently requested feature and it is added in XWD6. But the code at the end of the HTML is something new to me. This was never requested yet and I do not see obvious reasons for this to be mandatory. I suspect that the same code you add at the end would work just as well being inserted in the tracker field. In case it's not, I have to know more about the problem thus the question.
    Hi John,

    Sorry, I don't understand what you mean as I thought I had explained myself quite well. I create a page in XWD and choose Export so I get my file exported from XWD looking nice. This file contains placeholder code that runs on a section of the file which doesnt work.

    As you say it may well be that the code I add at the end will work okay in the Tracker field, I havent tested that yet. I have also just purchased XWD 6 as I wasnt aware of its release before now so that is downloading / installing currently.

    Does this help you understand what I need to achieve to get this particular file to work?

    Thanks


    In order to get this to work I need to open the XWD Exported file and go to the Beginning of the file and paste in this

    <? php
    ob_start();
    ?>

    Below here is the rest of the XWD generated file.

    Now at the very end of the XWD generated file on the last line, I paste this:

    <? php
    ob_end_flush();
    ?>

    To me that is adding code at the beginning and the end of the file and not just at the beginning of the file.

 

 

Bookmarks

Posting Permissions

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