Welcome to TalkGraphics.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2000
    Location
    Hautes Pyrénées, France
    Posts
    5,083

    Default dynamic php title tag

    I want to use php to populate each page's title tag and I can't find a reference to it on here, although I know it has been mentioned before. I'm therefore writing this short tutorial, partly so I can find the topic if I need to in the future, and also of course for the benefit of everybody else.

    For those who aren't aware, if you leave the Website and Page (i.e. both) "Description" and "Keywords" meta fields blank they are not added to the exported HTML pages. Therefore, filling them dynamically is easy using a placeholders, either site-wide or on a page by page basis.

    The <title> tag, however, is added whether you want it or not, and you can't add php code because if you do, this:
    Code:
    <title><php require("title.php"); ?></title>
    becomes this:
    Code:
    <title>&lt;php require(&quot;title.php&quot;); ?&gt;</title>
    when transmogrified by your Xara program.

    So what you need to do is remove the Xara-generated code starting <html> and ending </head> so that you can add your own section, including your dynamically generated <title></title> tag. To do this:


    1. Export your page, view source and copy everything at the top between <html> and </head> that was inserted by Xara (i.e. not any <head> code you may have added yourself)
    2. Create a placeholder object and give it the Name <html>(lower case)
    3. Go to the Placeholder tab, [HTML code (body)], insert start php and add the start of a multi-line comment (i.e. <?php /* )
    4. Click OK and Apply
    5. Go to the Page tab and click [HTML code (head)], insert the end of a multi-line comment (i.e. */ )

      If you were to click OK and Apply at this point, once uploaded to your server, your HTML page would have no <html> or<head> content (save what you may have added yourself). This is clearly unsatisfactory, so in the same Placeholder as 5) above:
    6. After the end of the php, paste the<html> section of the page you copied in 1. above, e.g.

      Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    Code:
     <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
     <meta name="XAR Files" content="php_htm_files/xr_files.txt"/>
     <title>Dynamic PHP Title Tag</title>
     <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252"/>
     <meta name="Generator" content="Xara HTML filter v.4.1.2.673"/>
     <link rel="stylesheet" type="text/css" href="php_htm_files/xr_main.css"/>
     <link rel="stylesheet" type="text/css" href="php_htm_files/xr_text.css"/>
     <script type="text/javascript" src="php_htm_files/roe.js"></script>
    7. Edit the <head> section, editing/adding your own code as required, e.g.
    Code:
    */ ?>
    
    <!-- start custom header -->
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <title><?php require("title.php"); ?></title>
    <meta name="keywords" content="<?php require("keywords.php"); ?>"/>
    <meta name="description" content="<?php require("description.php"); ?>"/>
    <meta name="Author" content="Billy the Fish"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="XAR Files" content="php_htm_files/xr_files.txt"/>
    <link rel="stylesheet" type="text/css" href="php_htm_files/xr_main.css"/>
    <link rel="stylesheet" type="text/css" href="php_htm_files/xr_text.css"/>
    <script type="text/javascript" src="php_htm_files/roe.js"></script>
    
    <!-- end custom header -->
    8. Click OK and Apply
    Writing this down methodically has helped me, although I know it's been mentioned elsewhere, but as usual the site search engine has thwarted me! Anyways, I hope it helps at least one person other than me
    If someone tried to make me dig my own grave I would say No.
    They're going to kill me anyway and I'd love to die the way I lived:
    Avoiding Manual Labour.

  2. #2
    Join Date
    Aug 2000
    Location
    Placitas, New Mexico, USA
    Posts
    41,519

    Default Re: dynamic php title tag

    I hope you added an appropriate tag. That will make it a lot easier to find in a search.

    It looks like a lot of work to me but it's good information for someone who needs it.

    Thanks M B.Gascone

  3. #3
    Join Date
    Dec 2000
    Location
    Hautes Pyrénées, France
    Posts
    5,083

    Default Re: dynamic php title tag

    it's not so much work when you consider it allows you to keep everything inside xara whilst giving you the flexibility of editing every single part of the html code, including everything at the top of the html pages - it's a godsend really
    If someone tried to make me dig my own grave I would say No.
    They're going to kill me anyway and I'd love to die the way I lived:
    Avoiding Manual Labour.

  4. #4
    Join Date
    Dec 2000
    Location
    Hautes Pyrénées, France
    Posts
    5,083

    Default Re: dynamic php title tag

    Found the original I knew I'd seen: http://www.talkgraphics.com/showthread.php?45457

    I suspect my revised edition is a little more thorough
    If someone tried to make me dig my own grave I would say No.
    They're going to kill me anyway and I'd love to die the way I lived:
    Avoiding Manual Labour.

  5. #5
    Join Date
    Dec 2000
    Location
    Hautes Pyrénées, France
    Posts
    5,083

    Default Re: dynamic php title tag

    a quick (important!) addendum to this tip. if you make changes to your web page/site, including any transitions, be sure to re-check the xara-generated headers and to include any lines to your own header code that have appeared in the xara-generated since you last did it. if not, you'll find things may work locally (because you're not running a php server) but won't on the server

    also, for those people absolutely paranoid about Xara references in their code, both <meta name="XAR Files" content="site_htm_files/xr_files.txt"/> and <meta name="xar files" content="site_htm_files/xr_files.txt"/> are correct
    If someone tried to make me dig my own grave I would say No.
    They're going to kill me anyway and I'd love to die the way I lived:
    Avoiding Manual Labour.

  6. #6
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,889

    Default Re: dynamic php title tag

    Quote Originally Posted by Big Frank View Post
    a quick (important!) addendum to this tip. if you make changes to your web page/site, including any transitions, be sure to re-check the xara-generated headers and to include any lines to your own header code that have appeared in the xara-generated since you last did it. if not, you'll find things may work locally (because you're not running a php server) but won't on the server

    also, for those people absolutely paranoid about Xara references in their code, both <meta name="XAR Files" content="site_htm_files/xr_files.txt"/> and <meta name="xar files" content="site_htm_files/xr_files.txt"/> are correct
    BF, this is very useful.

    To make it as simple as possible, here is my interpretation:
    1. Shape > Placeholder > HTML code (body):
      1. XXX - Anything you like over lots of lines
      2. Must finish with
      3. <!--
    2. Page > HTML code (head):
      1. -->
      2. <html>
      3. <head>
      4. YYY - Anything you like over lots of lines
    My way uses the HTML Comment to effectively remove the entire HEAD section.
    PHP code gets added to the XXX part; anything else can be added to the YYY part.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  7. #7
    Join Date
    Dec 2000
    Location
    Hautes Pyrénées, France
    Posts
    5,083

    Default Re: dynamic php title tag

    nice one
    there was a reason why i found a fault with using html comment
    but cant remember why now
    maybe something like html comment in php code or vice versa
    but its quick and easy and it works
    If someone tried to make me dig my own grave I would say No.
    They're going to kill me anyway and I'd love to die the way I lived:
    Avoiding Manual Labour.

  8. #8
    Join Date
    Dec 2000
    Location
    Hautes Pyrénées, France
    Posts
    5,083

    Default Re: dynamic php title tag

    Quote Originally Posted by Acorn View Post
    My way uses the HTML Comment to effectively remove the entire HEAD section.
    i think i just remembered why I don't use this
    the commented-out xara head section is still visible in the html if you use a html comment whereas if you use a php comment the xara head section never gets to the generated page
    If someone tried to make me dig my own grave I would say No.
    They're going to kill me anyway and I'd love to die the way I lived:
    Avoiding Manual Labour.

  9. #9
    Join Date
    Mar 2017
    Posts
    2

    Default Re: dynamic php title tag

    Dear members,

    i am new to this forum and got an issue concerning the php, read all the doc but feeling a little stupid as it seems that i am missing an info that everyone have figured out. i had no problem injecting in placeholders html,css, js. Everytime that i try injecting php by in a placeholder it is a fail .

    case 1 injecting in a placeholder
    <!DOCTYPE html>
    <html>
    <head>
    </head>
    <body>
    <b>
    <?php
    echo “hello world”;
    ?>
    </b>
    </body>
    </html>

    case 2
    renamed in the control center( xara 365) one of the page with the extension .php
    simple code <?php
    echo "Hello Browser!";
    ?>
    then i frame the file
    case 3
    inserted in another page a place holder with an iframe <iframe src ="http://camcap.xara.hosting/notepadph2.php" width="100%" height="100%"></iframe>
    got has a result an empty iframe, and if i tried to type the php page url (after publishing) error 404.

    then I have tried to put in a placeholder this i frame and it work fine
    <iframe src ="http://www.talkgraphics.com/showthread.php?t=46599" width="100%" height="100%"></iframe>


    My first question is that if i have web hosting by xara, should i be able to see the php file result in my browser when i type the url on the web or a local server is mandatory like wamp. I did not want to move to this solution until i set up a dedicated server as i want to do everything on my pc for the moment for security reasons.

    The second one is i have tried to rename the index page with the extension.php and keep an another page as htm and vice versa, but when publishing on xara web host another file indexhtm is automatically recreated, is there a specific way to do it.

    after trying many thing and reading some docs for example below
    http://site.xaraxone.com/tutorials/s...-website-host/
    https://www.talkgraphics.com/showthr...to-placeholder
    https://www.talkgraphics.com/showthr...-php-with-Xara

    what seems easy hasn't been for me, and would appreciate any detailed guidance methodology as my project cannot go ahead without php script.
    I have found a lot of comments positively orientated but unfortunately I cannot figure it out.

    Thank you for your assistance

 

 

Tags for this Thread

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
  •