473,320 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

best way to do this?

3
I have many pages with a unique short paragraph description for that page. Is it possible to have one text file for all of these paragraphs, and that each page could grab the appropriate paragraph from this one text file? I thought xml or AJAX might be the answer, but I'm not sure. I'd rather not have one text file for each html/php/whatever page, as that kind of defeats the intention of one easy file to edit. I've been looking for something like this for days, and have done lots of research, but can't quite come up with this method. And, of course, the text that shows up on the page needs to be searchable.
I'm open to any solution, and would welcome any suggestions.

Thanks in advance.
Aug 21 '08 #1
5 1375
Dormilich
8,658 Expert Mod 8TB
this depends on how you build each page.
You can insert via php an paragraph from one xml file using xslt (this is how I do it on my website). but I'm not familiar with searches.
Aug 22 '08 #2
SEWC
3
I was initially thinking xml and DOM parser.
XML Text file would be something like:
<page1Paragraph>This is the text that goes on page 1.</page1Paragraph>
<page2Paragraph>This is the text that goes on page 2.</page2Paragraph>
<page3Paragraph>This is the text that goes on page 3.</page3Paragraph>
etc.

Then have a loadXMLDoc function on each page with a <pageXParagraph>div.
I can't get it to work, though, and wondered if anyone had any ideas on this, or perhaps a better way to do it.

Everyone on this board seems sharp and well-rounded, so it looked like the best place to ask.

I found this script, but, while it worked locally, oddly, it didn't work when I tried it on a server. It's exactly what I need. (Except, of course, that it doesn't quite work.)
http://www.tek-tips.com/viewthread.c...443973&page=10

By searchable, I simply mean that I want the text embedded in the html, not like an iframe or Spry.

Thanks for your help.
Aug 22 '08 #3
Dormilich
8,658 Expert Mod 8TB
have you any means to find out why the script does not work on the server? (personally, I use the Firebug plugin for Firefox) My guess is, that maybe the XML file is not loaded correctly.
Aug 23 '08 #4
SEWC
3
It works locally only in Safari, not even in Firefox. Doesn't work on anything from the server. I'm ready to give up.
Doesn't anyone have some scripts that do this? DOM Parser, HTTPRequest? My pages are php.

Thanks!
Aug 23 '08 #5
Dormilich
8,658 Expert Mod 8TB
Ok, one possible solution using XSL:

part 1 - designing the xml file

this strongly depends on how you identify each page. You said you have quite a lot pages I recomment identification by id attribute (or similar).
Expand|Select|Wrap|Line Numbers
  1. <!-- DTD here if needed -->
  2. <desc>
  3.   <page id="1"><!-- description goes here --></page>
  4. ...
  5. </desc>
of course you can use any id value you like (e.g. numbers, characters, random strings)

part 2 - writing xsl

you get the <page> element you want by selecting the appropriate id.

Expand|Select|Wrap|Line Numbers
  1. <!-- xsl header declaration -->
  2. <xsl:param name="page">default value</xsl:param>
  3.  
  4. <xsl:template match="/">
  5.   <p><xsl:value-of select="child::page[@id=$page]" /></p>
  6. </xsl:template>
note: you have to set the <xsl:param> through php to get the desired result. the default is only a fallback.

part 3 - putting it all together

important note: as I'm using php4, xsl processing is quite different to php5, if you're using that please look up the xsl processing on www.php.net.
this function combines the xml and xsl and returns the result thereof. you might want to check, if there was an error or not.
Expand|Select|Wrap|Line Numbers
  1. $handle = xslt_create();
  2. echo xslt_process($handle, $yourXML, $yourXSL, NULL, array(), array('page' => $pageid));
  3. xslt_free($handle);
the thing you have to develop is how each site is connected to the ids in the xml file
Aug 23 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Gemini | last post by:
Hello I am looking for the best content/article manager software, perferred open source, php, mysql backend.. can anyone recommend me one? I think that the best discussion is phpbb, the...
18
by: Roman Suzi | last post by:
;-) Just type into google "best programming language" and press (I am lucky) Sincerely yours, Roman Suzi -- rnd@onego.ru =\= My AI powered by GNU/Linux RedHat 7.3
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
3
by: Irene | last post by:
Hi all, I have set up a simple VB program (and later on an ASP interface) to manage an Athletics database. I'm using Access 2000. To simplify, I have the Athlets, the Competitions and the...
5
by: l.woods | last post by:
I want your recommendation on which ASP.NET Shopping Cart software I should buy? Best code Best documentation Best support (if needed. I will buying source code, if possible) TIA, Larry...
4
by: Ron Brennan | last post by:
Good evening, Windows 2000, JDK 1.5. What opinions do people have on what way and tool programmaticly produces the best quality thumbnails from larger images? On the web I've seen Java...
7
by: Frank Millman | last post by:
Hi all Assume a 2-dimensional list called 'table' - conceptually think of it as rows and columns. Assume I want to create a temporary copy of a row called 'row', allowing me to modify the...
9
by: optimistx | last post by:
Which url in your opinion would be a good or even the best example of javascript usage in a set of pages at least say 10 or more pages? How to use css, how to split js-code to files, how to code...
24
by: Earl | last post by:
I have all of my data operations in a separate library, so I'm looking for what might be termed "best practices" on a return type from those classes. For example, let's say I send an update from...
9
by: =?Utf-8?B?QW1tZXI=?= | last post by:
I've read many incomplete opinions about the "Best Practice" for securely accessing SQL but what I really need to find the "Best Practice" that fits my applications needs. Currently (alpha...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.