* Website - adding a mini tree

Homeless Posts from the old forum system
Locked
avatar
Cambiz
Famous
Posts: 235
Joined: 26 Sep 2003 23:30
Family Historian: None

Website - adding a mini tree

Post by Cambiz » 29 Mar 2012 14:09

I want to add a small tree to each webpage.

Using Gedmills, I've created a number of .gifs and using an HTML editor can add the gif to the webpage.

However I have about 20,000 pages.

Each gif is numbered in line with the individual e.g. ind26790.html abd treeI26790.gif

I've taken a short look at Mike's Map Life Facts plugin code to see if I could amend it to suit the purpose, so instead of adding a link to the map for the person, it adds a link to the gif or the gif itself.

Is there an easy way in pspad to do this or could someone point out the part of the plugin that I could plagarise please.

see temporarily
http://www.camichaelfh.ukfamilies.com/mvow/fam3.html
for example - and I would be grateful if someone could tell me what I've done wrong re the picture (not the missing ones, I haven't ftp'd the data up for those yet)


ID:6056

User avatar
Jane
Site Admin
Posts: 8442
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Website - adding a mini tree

Post by Jane » 29 Mar 2012 14:27

Personally I'd write a plugin from scratch for this as it's a fairly simple job.

Also I'd put the diagram under the declaration text, which should avoid 'bouncing' the other images out the way and you can make it easy on yourself, by adding a place holder and then using gsub to replace the placeholder with the image link.

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Website - adding a mini tree

Post by tatewise » 29 Mar 2012 15:07

I think what Jane is saying is to use the wizard Step 8 - Final Details > Advanced button and enter a section, below menubar dummy tag place-holder.
You already appear to use something like that.

Then the Plugin simply loops through every ind*.html file and uses gsub() on each place-holder to update the matching HTML tag, or discard the place-holder altogether if no .gif image.

avatar
Cambiz
Famous
Posts: 235
Joined: 26 Sep 2003 23:30
Family Historian: None

Website - adding a mini tree

Post by Cambiz » 29 Mar 2012 20:49

Sorry, what do I do with the placeholder.

I can't see the plugin code you refer to in the snippets section.

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Website - adding a mini tree

Post by tatewise » 29 Mar 2012 21:44

You will need a loop to find each ind*.html file.
e.g.

Code: Select all

require 'lfs'      -- To access LUA filing system
local strDir = '..your website folder path..'
for strFile in lfs.dir(strDir) do
      if strFile:match('ind.*%.html') then
            local strPath = strDir..'\'..strFile
            local strText = StrLoadFromFile(strPath)
            strText = strText:gsub('<placeholder>','<img src='...gif'>')
            SaveStringToFile(strText,strPath)
            end
      end
end
The match() and gsub() functions are two of the many library functions available with LUA and documented in the Plugins > How to Write Plugins > Introduction to LUA or at LUA 5.1 Reference Manual.

The '' and '' find and replace strings will need adjusting to match your HTML code requirements.

The StrLoadFromFile() and SaveStringToFile() functions I could add to the Code Snippets library.  

avatar
Cambiz
Famous
Posts: 235
Joined: 26 Sep 2003 23:30
Family Historian: None

Website - adding a mini tree

Post by Cambiz » 29 Mar 2012 22:02

thank you

I'll give that a go

Locked