Welcome to Geeklog, Anonymous Thursday, November 28 2024 @ 11:56 am EST

Geeklog Forums

php + autotags in staticpages


Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
When I enable PHP in staticpages, the autotags are just displayed as text.

Why must I choose either PHP or autotags?
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
Hmm, could it be due to public_html/staticpages/index.php - function render_content:
Text Formatted Code

    if ($_SP_CONF['allow_php'] == 1) {
        // Check for type (ie html or php)
        if ($sp_php == 1) {
...
        } else if ($sp_php == 2) {
        } else {
            $retval .= PLG_replacetags ($sp_content);
        }
    } else {
        if ($sp_php != 0) {
            COM_errorLog...
        } else {
            $retval .= $sp_content;
        }
    }


 

And likewise in plugins/staticpages/functions.inc - function plugin_centerblock_staticpages:
Text Formatted Code

            if ($_SP_CONF['allow_php'] == 1) {
                // Check for type (ie html or php)
                if ($spresult['sp_php'] == 1) {
...
                } else if ($spresult['sp_php'] == 2) {
...
                } else {
                    $retval .= PLG_replacetags (stripslashes ($spresult['sp_content']));
                }
            } else {
                if ($spresult['sp_php'] != 0) {
                    COM_errorLog...
                } else {
                    $retval .= stripslashes ($spresult['sp_content']);
                }
            }


 


Get it? PLG_replacetags is only used if you to enable PHP (luckily that's the default) and use HTML! Is there a logical reason for this?!

Obviously requiring enabling general PHP support for this is a big nasty bug, but what about requiring HTML mode for the staticpage? Is it due to technical reasons (like something may go wrong with PHP when using autotags) or just a bug too?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
grumpy
Not sure what all the noise is about ...

So autotags are not replaced in static pages when $_SP_CONF['allow_php'] = 0. Congrats, you're the first one to notice that since autotags were introduced back in 1.3.10 (almost 2 years ago).

As for PHP code: You don't want PLG_replaceTags (or anything else for that matter) to mess with your PHP code. That could easily turn into a debugging nightmare. And since you're writing PHP code anyway, you can easily call it yourself when (and where) you need it.

bye, Dirk
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
Well, it's better late than never...it's still ironic that it may mess up the PHP yet it won't work with $_SP_CONF['allow_php'] = 0 Very Happy

I guess I didn't think about running PLG_replaceTags directly for each tag.

So what do you think - should I just do stuff like PLG_replaceTags("[bla:whatever]") or just put everything in $output and do an echo PLG_replaceTags($output) in the end (would this cause a nightmare too?)?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Calling PLG_replaceTags for the entire output should be a slightly faster than calling it for each snippet.

bye, Dirk
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
Well, da... Smile The question is whether calling it for the entire output has the potential to cause a "nightmare" too.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
My point above was that you should never run any sort of filter on actual PHP code. If it replaced something in your code, you could end up with a syntax error that's not there in the original code and therefore hard to track down.

bye, Dirk
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
So in other words...yes (it's ok to run it like I said).
 Quote

Status: offline

ronack

Forum User
Full Member
Registered: 05/27/03
Posts: 612
Might this be implemented in the next update?
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
Judging from every word Dirk has said in this topic...no.

But I do think there should be a disclaimer in edit mode that says "all HTML is allowed...autotags will only work in PHP mode if you manually run PLG_replacetags on your strings. Better yet, put them all in one string and use echo PLG_replacetags($string) in the end.

Plus, if only just for the principle, autotags should be supported even with $_SP_CONF['allow_php'] = 0.

So the only thing left without autotags is the blocks (in normal mode).
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
The above-mentioned bug has since been fixed in CVS. Although I would really urge people to use our bug tracker since things tend to get buried and forgotten in the forums ...

bye, Dirk
 Quote

All times are EST. The time is now 11:56 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content