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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 488
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 326
  • Total: 326

Things I've learned while creating php articles.

Started by JPDeni, August 22, 2006, 03:34:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JPDeni

1 -- If you need to create a form on your page, and you have a textarea in your form, you need to do a little extra work. If you use the closing </textarea> tag, it'll mess up the text editor and the only way you'll be able to back up is to go into the database and change it there. The way around it is to create a variable like this:

$textareaend = '<' . '/textarea' . '>';

early on in your script and use the variable to close your textarea. Something like

echo '<textarea name="text">' . $some_variable . $textareaend;

This will work.

2 -- When you create a new php article, just fill in the title and save it.  Don't post any code. Then click on the title in the list of articles to edit it and put your code in there. If you put it in at the beginning, all of your quotation marks will have slashes in front of them. Sometimes it works with the slashes, sometimes it doesn't, but it's really confusing. When you edit the articles it doesn't add more slashes.

3 -- You can pass variables in the URL, which opens up all sorts of things. I have a database of magazine articles that are in categories. When you first go to the page and there's no variable being passed, it gives a list of the categories with links. The links are to the same page, but with an additional category:

index.php?page=6;cat=5

When you click on a category, it gives a list of the articles in that category, each one with a link:

index.php?page=6;art=207

When you click the article link, it displays that article. I have over 200 articles in the database and all are displayed through one TP page. (Trying to avoid using the word article again.  :) ) I'm still trying to decide whether I'll change my setup with the upcoming changings to TP.

Php articles are really the main reason that I was drawn to TP. I tried mk_Portal and it said that you could create php pages, but I couldn't get it to work. mk_Portal had more modules available to start with, but with TP I could make all of my own.

IchBin

Thats great stuff JPDenni. Thanks for the info. I wish I had more time to dabble like you're doing. :)


bloc

Great info..and a good starting point for me to correct these issues as well. :)

JPDeni

QuoteI wish I had more time to dabble like you're doing.
Well, when you're a professional slacker, like I am, you've got the time. ;) I figure I can dabble and pass along the results of my dabbling for use by busy folks like you.
Quotea good starting point for me to correct these issues as well
But for the version after .95 or .96 or whatever the next one is, right? I hate to think that my posting delayed the new version.  :)

I did think that you might address some of the issues, so points one and two might be moot at some point. If you fix them, that's great, but it won't hurt anything if people continue to do those things.


JPDeni

I thought I'd add a few of the other things that I've learned, which might be of help to others.

4 -- Don't start and end your php box or php article with the php tags. PHP programmers are used to starting their code with
<?php
and ending it with
?>

It's not necessary within TP and, in fact, will cause your code not to work. The code in articles and boxes is used in an "eval" function and does not need -- can not use -- the opening and closing tags.

5 -- The "heredoc" structure will not work with the echo function, but will work with strings. You can not use
$name = 'Fred';
echo <<<EOT
You've got to call me "$name"!
EOT;


but you can use

$name = 'Fred';
$string = <<<EOT
You've got to call me "$name"!
EOT;
echo $string;


That one took me quite a while to figure out. Comes in very handy when you want to have some long text that may include single and double quotes and variables.

eldacar

index.php?page=6;&art=207You shouldn't need both ; and &. ; is prefered because a single & is not xhtml valid.

JPDeni

Thank you. I'm just getting into what is and isn't xhtml valid. I'll go edit it.

This website is proudly hosted on Crocweb Cloud Website Hosting.