Extract text to html href (a bit long)

T

text news

Sorry if this is a bit off base but I figured that this is about the only
place where I might find someone with the programing skills to help me out.

I am trying to marry together two pieces of software so that I end up with a
cheap and functional shopping cart.
(Don't laugh..... no abuse necessary!!)

My problem..... I have 500 photos to sell via the internet.

One piece of software "Easy Thumbnail Creator" generates the necessary pages
of photographs and some custom html to create an effective and simple
database of photographs that I can post to the internet.
The second piece of software "Mals E-Commerce" gives me the ability to add a
shopping cart facility to those pages of photographs.

Easy Thumbnail Creator uses a variable "#etcShortTitle" to turn the filename
of each photo into a unique descriptive name to identify each of the
photographs, so that variable could be "photo1", "photo2", "photo3" etc.,
matching their filenames "photo1.jpg" etc.

If there are, for example, 5 photographs to upload to the internet. Easy
Thumbnail Creator will automatically create an index sheet of thumbnails of
those photographs with hypertext links to "photo1.htm", "photo2.htm" .....
"photo5.htm". So far so good, it really works well.

Now to link to Mals E-Commerce also needs a bit of html.
A typical link is:

href="http://www.aitsafe.com/cf/add.cfm?userid=6226543&product=photo1&price=
4.95"

The tricky bit is where it says "product=photo1" as that is the identifier
that I need to include.

In an ideal world I would be able to use the variable "#etcShortTitle"
(which represents the "product") used in Easy Thumbnail Creator to directly
insert the appropriate product identifier in the href line needed for Mals
E-Commerce, but that is not possible, although if it was it would look a bit
like:

href="http://www.aitsafe.com/cf/add.cfm?userid=6226543&product="#etcShortTit
le"&price=4.95"


One solution that might work (this is where you roll around the floor
laughing!!!!) is a sort of search and replace.

I could use Easy Thumbnail Creator to generate all the html pages and
include the same line in each page:

href="http://www.aitsafe.com/cf/add.cfm?userid=6226543&product=xxxxx&price=4
..95"

Note "product=xxxxx", I could do a simple text search and replace on "xxxxx"
but my problem is that the replace text would be different for every page of
html. I need to somehow "read" the piece of text from the top of the page.

Within Easy Thumbnail Creator I could write the html so that in a fixed
position, say the very first word of the page, it puts the unique product
name, say "photo1" for example.
I could then run a piece of software (this is where you guys come in) that
would open the first page of html, copy the first word "photo1" search for
"xxxxx" and replace it with "photo1". Then open the next page of html and
repeat in loop until all pages have been modified. A simple text based
search and replace but one that reads the "replace" word from a fixed
position on the page.

Did this make any sense?
Can anyone help?
There is quite a bit of software that can do multi file search and replace
but I have not found anything that can use a string of characters that it
reads from the start of a text file as the replace string. Oh and the
numbers may not be consecutive, they may jump "photo1", "photo3",
"photo127", hence the need to read the string from the text.

Oh to be 20 years younger and have a brain........

Thanks for reading this far

Best wishes from Les
 
T

Toddy Marx

text said:
Sorry if this is a bit off base

Yeah - my ideas for your problem would probably fit more into
news://comp.unix.shell.
...
Within Easy Thumbnail Creator I could write the html so that in a fixed
position, say the very first word of the page, it puts the unique product
name, say "photo1" for example.
I could then run a piece of software (this is where you guys come in) that
would open the first page of html, copy the first word "photo1" search for
"xxxxx" and replace it with "photo1". Then open the next page of html and
repeat in loop until all pages have been modified. A simple text based
search and replace but one that reads the "replace" word from a fixed
position on the page.

If you have the chance to work on a Unix system the following script
might do the task. You would need to replace "./srcdir" with the path
of the directory where you placed the "Easy Thumbnail Creator" files.
The files produced by "Easy Thumbnail Creator" should have no
extension.


#!/bin/sh
#
# Loop over all files in $DIR and
# get 1st line of file,
# replace $PATTERN with content of 1st line,
# save file with new extension.
#

# directory with files
DIR=./srcdir

# pattern that is to be replaced
PATTERN=\#etcShortTitle

# extension of new files
EXTENSION=html

for src in $DIR/*; do
image=`less $src | head -1`
sed s/$PATTERN/$image/ $src > temp
mv temp $src.$EXTENSION
done



Hope this hepls!

~Toddy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top