|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
November 1st, 2006, 06:43 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
content management system
Hi there
I've built this bespoke CMS for a client but want to add a facility whereby if he types a url in his text i.e www.mysite.com, then it will convert to an active link when embedded in the front end web page - i.e
<a href="http://www.mysite.com" target="_blank">www.mysite.com</a>
Can anyone advise me?
thanks
Adam
|
November 1st, 2006, 11:51 AM
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How is your content stored as far as markup goes? Is your content XML or merely text?
Do you provide an editor to the user so they can indicate metadata about the content - that is, to indicate paragraphs, titles, headers, boldness, colors, etc? Typically, if this is all stored as XML then you could also allow them to indicate links, which your code (hopefully XSLT) will then handle.
Properly done (in my opinion) content should be stored with markup as XML for this very reason. It can then be transformed to whatever output you need - HTML, rtf, etc.
Now... assuming that the content is not stored as xml, you will need to write code that will find the pattern of a link in the content and convert it to an anchor element (the a href=...). Regular expressions are the standard (and in my opinion best) way to do this.
Woody Z http://www.learntoprogramnow.com
|
November 1st, 2006, 11:58 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
In either situation you need to write code to look for a pattern; if you go the route of XML then you need to write code to identifiy that a url exists and place it into your XML accordingly. (You also could probably do this in XSLT to look for a url and mark it accordingly)
And, even if you aren't using XML, you are still going to need to match a pattern in your code.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
November 1st, 2006, 08:15 PM
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by dparsons
In either situation you need to write code to look for a pattern; if you go the route of XML then you need to write code to identifiy that a url exists and place it into your XML accordingly. (You also could probably do this in XSLT to look for a url and mark it accordingly)
And, even if you aren't using XML, you are still going to need to match a pattern in your code.
|
If you are using XML there is no need for pattern matching. That is the whole point and purpose of the xml. If you process the XML using code, you will work with the DOM and XPath to navigate to and operatate on the various elements - in the case of URLs you will then have your code wrap the URL in the anchor element (the a href tags). If you are using XSLT, you will simply use a call-template or a match template to process URL elements (that is, items that are marked with an element you use for this purpose).
Again - the reason I like XML for content markup is the same reason that the printing industry has used SGML for decades - formatting is separated from the content - you can format your output easily in any conceivable manner as long as you have a logical system for marking up the content. For example, if your content is stored as xml, you can easily output it as HTML, but you can just as easily output it as instructions to a Braille device, a human voice simulator, a typesetting application, or whatever.
Additionally, you can use XML content to generate menus, a table of contents, synopsis output, outlines, or whatever - all from the same content. As long as you put the content into the XML that you later wish to use, and mark-up the various uses of each discrete item of data - then you are in very good shape to be as creative as you want in devising the output.
Also, it is relatively easy to create XML from content that is stored in database tables and dynamically build XML from those parts of the content that are stored in an "un-marked-up" form.
Woody Z http://www.learntoprogramnow.com
|
November 2nd, 2006, 08:44 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
You simply reiterated what I said in more detail.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
November 2nd, 2006, 02:07 PM
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by dparsons
You simply reiterated what I said in more detail.
|
? Not at all! This is what you said:
Quote:
quote:Originally posted by dparsons
In either situation you need to write code to look for a pattern
|
And that is not what needs to be done if using XML. Using the XML DOM or XSLT we are not looking for patterns, we are accessing nodes. These are entirely different mechanisms.
Woody Z http://www.learntoprogramnow.com
|
November 3rd, 2006, 09:25 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well, thanks for that guys - sounds complicated especially as the CMS is built with ASP and not XML or XSLT. At present, it doesn't allow for metadata.
|
November 3rd, 2006, 09:33 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Quote:
quote:Originally posted by Adam H-W
Well, thanks for that guys - sounds complicated especially as the CMS is built with ASP and not XML or XSLT. At present, it doesn't allow for metadata.
|
When you place the data into your database you can search to see if a valid URL exists somewhere in the string and replace it with an actual A HREF then, when its displayed, it will be an active link.
Of course, depending on your system, you will have to catch http://www.mysite.com, http://mysite.com, www.mysite.com
hth
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
November 3rd, 2006, 11:31 AM
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by Adam H-W
Well, thanks for that guys - sounds complicated especially as the CMS is built with ASP and not XML or XSLT. At present, it doesn't allow for metadata.
|
First of all, you can easily use XML and XSLT in an ASP site. How is it that you can have a CMS without metadata?
Woody Z http://www.learntoprogramnow.com
|
November 4th, 2006, 10:33 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In the CMS, it only provides the facility for the user to add/edit/modify text and images without using other functions such as text colour, links, boldness etc. They don't have the ability to 'style' their text.
|
|
|