I want to generate Dreamweaver templates from FW. It’s all good except for the document Title tag. I need to either remove the existing tag and replace it with HTML markup (which will include the title tag), or wrap the title tag (the whole tag, not just the title text) in markup.
Can anyone point me in the right direction for the action commands that can do this?
BTW, is the Actions Reference edition 1 still the current version? And does anyone know if it has a contents or index page?
Happy to help. Can you please show me an example of the code you want to insert? Before and after would be helpful. You can get ahold of the title tag in the usual way:
var title = fwDocument.fwTags.fwFind('title');
Once you have that reference, you can alter it or its content in any number of ways, or wrap it with another tag.
Walter
On Feb 22, 2013, at 8:07 AM, Ian Webb wrote:
I want to generate Dreamweaver templates from FW. It’s all good except for the document Title tag. I need to either remove the existing tag and replace it with HTML markup (which will include the title tag), or wrap the title tag (the whole tag, not just the title text) in markup.
Can anyone point me in the right direction for the action commands that can do this?
BTW, is the Actions Reference edition 1 still the current version? And does anyone know if it has a contents or index page?
Here’s a code snippet that you could possibly use as-is that was taken from a set of Actions I created for a PHP based CMS;
var title = fwDocument.fwTags.fwFind("title");
if (title){
var newTitleMarker = title.fwAddEnclosing("",false);
var newtitle = newTitleMarker.fwAddRaw("<?php build_title($ptitle); ?>");
var newTitleTag = newTitleMarker.fwAddEnclosing("title",true);
//remove the old title
title.fwDelete();
//add a comment to the template
var commentMarker = newTitleTag.fwAddEnclosing("",false);
commentMarker.fwAddRawln("<!-- title -->",commentMarker);
}
Regards,
Tim.
On 22 Feb 2013, at 13:07, Ian Webb wrote:
Can anyone point me in the right direction for the action commands that can do this?
Both Tim and Walter replying? - Blimey, I’m in the presence of giants
I’ve got it now, but Tim - if you’ve got a second - I’m confused by part of your code. You define var newtitle, but then don’t seem to use it again - what does it do?
Hi Ian,
You can do this sort of thing several ways including, as you did, adding markup to the parent item. The only downside to this technique, assuming you are adding HTML-like tags, is that you won’t easily be able to find that item again with the same or another Action. If you find the title tag you can either find all of its children (normally just a single string of text), and replace this with your markup or you can wrap the old title in a new one, add your new title content and then delete the old title tag. This is how that example I sent works.
As I say depending on what you need to add there are several ways to address the problem.
Regards,
Tim.
On 22 Feb 2013, at 13:38, Ian Webb wrote:
Basically, I found the title tag, then found its parent. Added raw markup after the title tag, then deleted the old title tag.
Hi Ian,
That is more my way of doing things than anything else. I tend to assign items to variables regardless of if I need them now just in case I need to address them later on in the code. I’d admit that it’s possibly a drain on Freeway’s memory if not used but it does allow me to easily get back to the item if I need to.
Regards,
Tim.
On 22 Feb 2013, at 13:48, Ian Webb wrote:
I’ve got it now, but Tim - if you’ve got a second - I’m confused by part of your code. You define var newtitle, but then don’t seem to use it again - what does it do?
Hi Ian,
Locating the title content and replacing the content would preserve it. My suggested code deletes the tag but adds a new one into the tag tree so that another Action can still locate it later in the publishing process. Adding content using fwAddRaw is generally considered only useful for non-tag content as you can’t locate any tags using fwDocument.fwTags.fwFind.
Regards,
Tim.
On 22 Feb 2013, at 13:56, Ian Webb wrote:
So, my method destroys the title tag by removing it from the tag tree, and yours preserves it - is that right?
I have an action that allows you to change the title of a page, it is al old FW action that I took further for my own PHP pages.
Most ‘if not all’ the web pages I write are in PHP and I hated the confusion from page names on the FW site pane so I used the old action as a base and called mine: ‘PHP Dynamic page titles’. You can name your page as you like, say CONTACT, HOME, PRODUCTS etc. then:
Apply the page action.
Name a variable in the action, say $pageTitle
Set some PHP code in the Before HTML of the FW page mark up, something like:
<?php $pageTitle = 'This is my home page'; ?>
Select in the action if you want to use your existing page title before the $pageTitle text, after it or just the $pageTitle text.
Make sure your page is .php
Upload
See your dynamic page title
Is this what you are looking for? If you think this to be any help to you let me know and I will send you a copy.
HTH
On Feb 22, 2013, at 2:38 PM, Ian Webb wrote:
Hi Walter!
I’ve just sorted it! I shouldn’t have underestimated (1) FW’s documentation, (2) FWtalk’s enthusiastic members!
Basically, I found the title tag, then found its parent. Added raw markup after the title tag, then deleted the old title tag.
Any comments or suggestions?
Cheers, Ian.
BTW, I posted a comment on your External stylesheets on Actionsforge - any chance you could have a look? (the actionscript is WAY beyond me!)