Closed Thread Icon

Topic awaiting preservation: Repeating a Block of Text/HTML (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=22480" title="Pages that link to Topic awaiting preservation: Repeating a Block of Text/HTML (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Repeating a Block of Text/HTML <span class="small">(Page 1 of 1)</span>\

 
Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 07-08-2004 15:57

OK, OK, I hate to post this here, but I couldn't decide which scripting forum to place it in since the whole question in the first place is about the best method for doing this ...

I'm updating my FAQ for the good ol' Big Waste of Space. And I've got so many Q's that I'm dividing them into categories. The problem is that now some of the Q's can go under more than one category. (Which I've decided must happen since I know most people will not look in more than one place to find their Q.)

So, what I would like to do is write the Q, its A, and the associated styles once, and insert the whole block in multiple places. (Not with all of them, just the repeated ones.)

I know I can do this with SSI, but I'm trying to avoid creating multiple files for each repeated question. I'd like to either keep everything on one page (my preference) or at most put the Q's that get repeated together on one separate page.

Let's here what you all think would be the best and most easily managed solution.

Iron Wallaby
Paranoid (IV) Inmate

From: USA
Insane since: May 2004

posted posted 07-08-2004 16:14

PHP, Perl, Python, or any server-side language can do the trick. You can store the questions/answers in a data structure, and then print them out (possibly multiple times each) in the order that you want them to go.

Probably the best way to do it is store all the questions/answers in a seperate datafile, and read it in to fill your data structure. That would make it easy to update and maintain.

"Any sufficiently advanced technology is indistinguishable from magic." -- Arthur C. Clarke
"Any sufficiently arcane magic is indistinguishable from technology." -- P. David Lebling

(Edited by Iron Wallaby on 07-08-2004 16:15)

kuckus
Bipolar (III) Mad Librarian

From: Berlin (almost)
Insane since: Dec 2001

posted posted 07-08-2004 16:16

If you have PHP available you could have two big arrays, which contain all the questions and answers, in a PHP block at the top of the file, and then further down wherever you want to have them outputted echo() the stuff in the appropriate order.

E.g.

code:
<?php

$questions[0] = '<p class="...">Can you tell me where such-and-such...</p>';
$answers[0] = '<p>Probably not. I love finding and visiting movie locations, but.....</p>';

$questions[1] = '<p class="...">I'd like to use one of the pictures...</p>';
$answers[1] = '<p>Usually, it's no problem. But I do insist.....</p>';
.
.
.
?>



Then to print question 2 twice you'd just do something like

code:
echo $quesions[1] . $answerd[1];
echo $quesions[0] . $answerd[0];
echo $quesions[1] . $answerd[1];



(Edited by kuckus on 07-08-2004 16:18)

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 07-09-2004 20:31

I figured PHP would probably dominate the asnwers to this question. I'll give it a shot and post any problems in the appropriate forum. Thanks!

lan
Bipolar (III) Inmate

From: Darwin, NT, Australia
Insane since: Dec 2003

posted posted 07-10-2004 00:45

Wes, Wes, tut, tut; not at all like you : " Let's here what you all think"! What's the world coming to?

[running] Heads for nuclear shelter[/running] Why bother, he'll get me anyway

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 07-10-2004 07:45

Hey, in some areas, I'm not so smart.

These areas, however, are small in scale and number.

lan
Bipolar (III) Inmate

From: Darwin, NT, Australia
Insane since: Dec 2003

posted posted 07-10-2004 09:33

Wes, tell me you didn't miss it again, puuuleeeze! Perhaps all this verbing is affecting my hearing

[edit] Sorry Wes, on reflection it seems a bit picky; just couldn't resist what with the verbing an' all[/edit]

(Edited by lan on 07-10-2004 10:14)

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 07-12-2004 14:36

Eh? What? Oh ... I don't sleep much these days ...

Hear, hear ...

« BackwardsOnwards »

Show Forum Drop Down Menu