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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,972
  • Latest: Lineo
Stats
  • Total Posts: 196,106
  • Total Topics: 21,345
  • Online today: 1,072
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 135
  • Total: 135

Question about PHP in article and PHP box

Started by Rasyr, January 02, 2006, 01:21:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rasyr

Not quite sure how to use this.

Do I have to include the <?php and the ?> tags in the content boxes or is that something that is already dealt with considering the entire site is php?

I have seen the PHP in articles link to the left, but that only shows the result, not the "how do I get that result" portion.

Any help is appreciated.

gerrymo


Rasyr

Cool! Now all I have to do is to learn PHP.....  :)

Another question:

Given how TP is setup, is it fully possible to use the SMF variables and settings (and such) in these articles. For example, would I be able to pull a user's membername (or whatever it is actually called), and use that in a PHP article?

I am suspecting that the answer is yes, but I would like to be sure.

gerrymo

You can use SSI for a lot of things. Go to your own ssi_examples.php page like this: http://www.tinyportal.net/smf/ssi_examples.php To use a function ignore the part about the 1st line. And take off the php tags. For instance, to get "Who's Online", use:

ssi_whosOnline();


And not

<?php ssi_whosOnline(); ?>


This is of course for php articles or blocks.

Rasyr

Cool!!! The more I find out about TinyPortal, the more and more I like it!!!

I do have a question though, I tried the three different ssi poll functions, and while they showed the poll (well the only poll) if the user had not voted, once he voted, the poll box was empty.

How would I go about making it show the results of the poll once the user had voted?


bloc

You need to change the SSI.php for this..its in fact made that way..but i think its changed for 1.1RC2, not sure though.

And yes, all settings avaiable in SMF is also available in TP. Sometimes you need to set a Global on them, but mostly they are there. You can write a article(php type) and simply add the members name to it. Like...


global $context;

echo '<h3>Dear ';
echo $context['user']['name'];
echo '!!</h3> Welcome to our page!';


..and it would display the membername to whoever is reading it. Even guests get a "guest" name..or you could rather check if its a guest and do something else, like:


global $context, $scripturl;

if($context['user']['is_logged'])
{
   echo '<h3>Dear ';
   echo $context['user']['name'];
   echo '!!</h3> Welcome to our page!';
}
else
{
   echo '<h3>Hello visitor!!</h3>';
   echo 'Welcome to our page! Maybe you like to <a href="'.$scripturl.'?action=login">login?</a>';
}


Doing it like that you could present a different page for visitors and members, just as long as you keep the member-stuff in between the first 2 brackets. The second bracket set is shown for guests.

This website is proudly hosted on Crocweb Cloud Website Hosting.