Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Text appearing based on items

10 years ago
I imagine there is a simply solution to this, but I'm not seeing it:

I have a block of text that I want to appear at the end of the text on a page (but before the items, in the normal place). However, I only want the text to appear when the reader has a specific item in place. I was trying to find a way to make the usual text "if" statement to work, but I was trying to combine that with the ITEMSTATE variable:

%%$ITEMSTATE2%=%1%Fun, exciting text to appear here.%%

Is there a way to make this work, and I'm just missing the formatting? I mean, I could see another way to make it work by creating a new variable and putting IF code in the script on the page, but that seems needlessly complex.

Text appearing based on items

10 years ago
Dang it. I knew if I kept playing around with it, I'd find a way. Never mind, no need to answer the question, I found a way that worked (that I didn't think would work).

For those interested in doing this, you can add the script code in the page script and just add to $PAGETEXT. Apparently anything you add to $PAGETEXT in there appears at the END of the page text, which is not what I expected, but hey, it works perfectly for what I need it to do!

Text appearing based on items

10 years ago

You need to go to the page's script and input:

IF $ITEMSTATE2 = 1 THEN $PAGETEXT := $PAGETEXT + "Fun, exciting text to appear here."

Edit: Nevermind, I see you got it.

Text appearing based on items

10 years ago
Hey, thanks for chiming in!

Text appearing based on items

10 years ago

Sorry, I didn't mean to burst in, since you already fixed the problem, but I will add a little bit of info that may help. If you have RTE turned off, $PAGETEXT can be used to insert HTML/CSS/JavaScript.

For instance:

$PAGETEXT := $PAGETEXT + "<p>New Text"

This will put the new information in a new paragraph, distinguishing it from the present text.

Text appearing based on items

10 years ago
Ah yes, I've tried that with CSS and HTML. I hadn't put any JavaScript in there... I suppose I could make some weird things happen with that to text in the reading block...

Text appearing based on items

10 years ago
I used it to make a party management page with show/hide links.

Text appearing based on items

10 years ago
The show/hide links was exactly what I was thinking about and where I could have some fun...

Text appearing based on items

10 years ago
I think I have my code saved to an HTML document somewhere. I can PM it to you, if you want.

Text appearing based on items

10 years ago
Oh hey, if it's handy, that would be cool. If not, no worries!

Text appearing based on items

10 years ago
Yep, just found it.