SimplePortal

Support => English Support => Topic started by: wjhdiz on September 13, 2010, 11:50:52 AM

Title: Help: How to call a SSI.php function within a customized php block?
Post by: wjhdiz on September 13, 2010, 11:50:52 AM
Hi,

I want to make a customized php block with some jquery tabs script like

Code: [Select]
        <div id="container-1">
            <ul>
                <li><a href="#fragment-1"><span>One</span></a></li>
                <li><a href="#fragment-2"><span>Two</span></a></li>
                <li><a href="#fragment-3"><span>Tabs are flexible again</span></a></li>
            </ul>
            <div id="fragment-1">
                ssi.php function-1
                <pre><code>$(&#039;#container&#039;).tabs();</code></pre>
            </div>
            <div id="fragment-2">
                ssi.php function-2
            </div>
            <div id="fragment-3">
                ssi.php function-3
            </div>
        </div>

Any help is greatly appreciated.

Thanks in advance.
Title: Re: Help: How to call a SSI.php function within a customized php block?
Post by: AngelinaBelle on September 13, 2010, 02:16:29 PM
This is not strictly a SimplePortal question.
This is php question -- how do you call a function?
 
The short answer is
1) make sure the function is defined (by using require_once for the file with the function definition)
2) Call the function
 
In this case, the function definitions you want are in an SMF file called SSI.php, so that's the file you need.
 
SMF provides some information on how to use the SSI functions:
http://demo.simpleportal.net/ssi_examples.php (http://demo.simpleportal.net/ssi_examples.php) (for example -- there is one in your SMF installation, too).  In a SimplePortal custom php block, though, you don't use the <?php tag of course. And you want to use require_once instead of require, just in case the file has been included earlier.
 
For an example of SimplePortal code calling an ssi function, look in PortalBlocks.php for ssi_BoardNews.
 
Title: Re: Help: How to call a SSI.php function within a customized php block?
Post by: wjhdiz on September 13, 2010, 11:40:06 PM
Here this one works:

Code: [Select]
echo' <div id="tabs">
<ul>
<li><a href="#tabs-1">First</a></li>
<li><a href="#tabs-2">Second</a></li>
<li><a href="#tabs-3">Third</a></li>
</ul>
<div id="tabs-1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div id="tabs-2">Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.</div>
<div id="tabs-3">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.</div>
</div>';

What I don't like is this does not call SSI.php functions. If I want to say add

<?php ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo'); ?> within <div id="tabs-1"> </div>, how should I get this through?
Thanks.
Title: Re: Help: How to call a SSI.php function within a customized php block?
Post by: AngelinaBelle on September 14, 2010, 06:32:34 AM
I can see you are just getting started with programming.
Your question is really just about php programming, rather than about SimplePortal or even about SMF.
You would probably enjoy the php tutorial at http://w3schools.com (http://w3schools.com). There are many other good tutorials, and the manuals at php.net are a very good reference.
 
If you would like to see some php code in action in a SimplePortal block, you can have a look through PortalBlockks.php.  You'll even find function sp_recent, and see how it calls ssi_recentTopics or ssi_recentPosts.
 
---------------
It is also possible that you can achieve the effect you want by calling several SimplePortal blocks directly, in a blocks in blocks technique: http://simpleportal.net/index.php?topic=5332.0 (http://simpleportal.net/index.php?topic=5332.0)
---------------
Since you are already in php mode, you don't have to switch into php mode.
You can handle this simply by ending the echo statement, doing your statement, then doing another echo statement.
 
Code: [Select]
echo'      <div id="tabs">
         <ul>
            <li><a href="#tabs-1">First</a></li>
            <li><a href="#tabs-2">Second</a></li>
            <li><a href="#tabs-3">Third</a></li>
         </ul>
         <div id="tabs-1">
';
         ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo');
 
          echo '</div>
         <div id="tabs-2">Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.</div>
         <div id="tabs-3">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.</div>
      </div>';
Title: Re: Help: How to call a SSI.php function within a customized php block?
Post by: wjhdiz on September 14, 2010, 10:04:53 AM
Thanks Angelina.

I am pretty sure this will work. I tried earlier by putting

Code: [Select]
<?php ssi_recentTopics($num_recent 8$exclude_boards null$include_boards null$output_method 'echo'); ?>directly and it surely got error.

This urgent party of my site and really don't have time to go through tutorials. I am readinga book now, but will take some time to bring me to the level needed to work this out.

Thank you very much.
Jimmy
Title: Re: Help: How to call a SSI.php function within a customized php block?
Post by: AngelinaBelle on September 15, 2010, 09:22:00 AM
Does that solve the problem?
 
Good luck getting started, and I hope you will enjoy learning more about programming.
Title: Re: Help: How to call a SSI.php function within a customized php block?
Post by: wjhdiz on September 21, 2010, 11:10:56 PM
Yes, I am becoming more motivited and feel that I have done quite a lot on what I want to with help from good people here.

Thanks.

P.S. Did you realize that ssi_recentEvents returns only today's event? I found it yesterday and posted on simplemachines.org.
Title: Re: Help: How to call a SSI.php function within a customized php block?
Post by: AngelinaBelle on September 22, 2010, 09:14:51 AM
Please see http://simpleportal.net/index.php?topic=5332.0 (http://simpleportal.net/index.php?topic=5332.0)
 
You can actually use the calenderInformation block within your tab.
If you are interested, please start a new thread.
Title: Re: Help: How to call a SSI.php function within a customized php block?
Post by: wjhdiz on September 24, 2010, 11:47:18 PM
Hi Angelina,

I followed the link and then called sp_calendarInformation(array('events' => 1, 'holidays' => 1, 'future' => 15), 0) and it turned out great.

Thank you so much.
SimplePortal 2.3.8 © 2008-2024, SimplePortal