TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 18, 2024, 11:11:07 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,164
  • Total Topics: 21,219
  • Online today: 203
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 70
  • Total: 70

Weird php block reaction

Started by Ayan, July 24, 2009, 07:43:51 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Ayan

Haha.  Tested on a live site with the UTF-8 encodings, and no joy.  So, I guess I'll have to go back over everything again.

Ayan

I finally found the problem!  Now to solve the root issue.  I'm using a mouseover tooltip (wz tooltip) to display images out of an array.  In order to make the tooltip work, all of the HTML double quotes (") need to be converted to the HTML character entity (").  Like this:


Correct:
'thumb' => '<img src=&quot;/images/class_spec/lds.jpg&quot;>',
Incorrect:
'thumb' => '<img src="/images/class_spec/lds.jpg">',


When I copy the code into the block and hit save, the php script works flawlessly.  When I go back in to edit one of the recruiting requirements, Tiny Portal (or whatever is handling the script) converts all of the (&quot;) back to (") which "breaks" the  scripting.


So, anyone know a way around this problem?

JPDeni

Ah-ha!

Well, I congratulate you on finding the problem. I'm not sure what to change, though. I'll see if maybe Bloc will have some ideas.

Ayan

#13
I'd appreciate it.  Thanks!   I didn't know that HTML could change like that, but I'm learning.   I cut out all of the data arrays except one to work with, and   I spotted it quite by accident, when I was going over every line.  Oddly, that was the last place I was looking for a problem to crop-up.  I have been doing some looking on my own, but haven't found any references to this specific problem, unless I'm googling it using inappropiate terminology.

I'm wondering if a better option wouldn't be to store the arrays in a seperate file and try to call them with the display part of the coding.  But, I can see that getting really messy really fast trying to update variables into a block, sending it to a file to define the variables in the arrays and sending it back to the block to create the display.

Maybe I'm up way too late puzzling this out and will program myself into hell trying to work on it any more tonight, lol.  Besides, I don't think the boss will buy the "No, Really!  I wound up trapped in Hell!" excuse if I come in late for work tomorrow.

JPDeni

:D

I did a little bit of looking and it appears that the "culprit" is the use of html_entity_decode when the blocks and articles are saved. If you want to be brave :) you can try going into the Sources/TPortalAdmin.php file and remove that function. There are several places where it exists, but you probably only need to worry about the one that deals with blocks, which appears to be the line


$context['TPortal']['blockedit']['body']=html_entity_decode($row['body']);


Try changing it to


$context['TPortal']['blockedit']['body']=$row['body'];


and see what happens. If you get a crash, change it back.

Ayan

#15
Wow, finding such a function is pretty amazing.  Alas, to no avail.  My next step was to go through and backup every TP file, and search them for the html_entity_decode function, and remove them all.... from every TP file I could find.  Still, it is decoding the entity.  Are there any other files I should look at?  For instance, does SMF have an overriding factor here?

PS.  Search engine results on this are negative for Tiny Portal, except a few entries in portugese or swahili.

JPDeni

I had another thought. You might be able to get it to work by altering your php code a bit.

Instead of


'thumb' => '<img src=&quot;/images/class_spec/lds.jpg&quot;>',


Try setting a variable

$quote = '&quot;';


and then using it in your array


'thumb' => '<img src=' . $quot . '/images/class_spec/lds.jpg' . $quot . '>',

Ayan

That's an interesting take.  I'll give it a shot.  You may have helped me inadvertently with another... "coding of convienience" problem I was working on for a few hours last night.  I was unable to get a variable string working inside if the <img src=***> last night at all, even using a few examples of snippets I found in the snippets board.  I may end up owing you a batch of cookies....

JPDeni

LOL!

There is a problem with creating textareas in forms in a php script as well and this is similar to the workaround I figured out for that. I just remembered it when I woke up this morning. Sometimes things need to "fester" a while in my brain. ;)

Ayan

#19
That was a really creative solution to that problem, JPDeni.  Bonus that I didn't have to alter the core TP files to do it.  I'm really starting to appreciate how flexible this language is.  If I had any pull, I'd nominate you for the Nobel 'php'iece Prize.  Guess you'll have to settle for cookies!  PM me where to send them :-)

Now that it works (as intended), time to make it look pretty.... Doh!

BT-Dubs, you solved my other "code of convienience"  issue too.  Let's hope when I get this home to my SMF 1.1.10/TP 1.0 B4, it continues to work!