Help me edit my SSI.php

Started by bugzy, July 16, 2009, 10:56:05 PM

Previous topic - Next topic

bugzy

Hello I'm using the recent post feature of SSI and I want to edit something on the code but I don't know php becuase I'm no programmer.

Here's what is showing on my main website.

[NAME OF THE CATEGORY]  NAME OF THREAD  by POSTER   Today at 06:12 AM 



I want to format it this way


POSTER : NAME OF THREAD - Today at 06:12 AM 



Is it ok to upload my SSI.php here?


Thanks!

Akyhne

Moved to SMF coding discussion.

You shouldn't be editing existing functions, but make a copy of the one you want to edit and rename the function. Besides that, i can't help you. Wait for someone else to reply.
Uploading your SSI.php is alright.

bugzy

Ok thanks! Hope someone knows this.

Arantor

You don't actually need to edit SSI.php at all. Nearly all of the SSI functions that output things don't have to output - they can return the information into an array that you can display how you want.


<?php
require('forum/SSI.php'); // or whatever the path is to it
$posts ssi_recentPosts($num_recent 8$exclude_boards null$include_boards null$output_method 'array');
echo 
'
<table border="0" class="ssi_table">'
;
foreach (
$posts as $post)
echo '
<tr>
<td valign="top">
'
$post['poster']['link'], ' : <a href="'$post['href'], '">'$post['subject'], '</a> - '$post['time'], '
</td>
</tr>'
;
echo 
'
</table>'
;

?>


bugzy

Aranto I have this error:



Please don't access SSI.php by URL directly; you may want to use the path ('SSI.php') or add ?ssi_function=something.
Fatal error: Call to undefined function ssi_recentposts() in /home/sample/public_html/mywebsite.com/wp-content/themes/sports/home.php on line 29



I want this format:

Poster: Name of thread

Poster is not clickable and should be color blue..


Arantor

Like I said you don't modify SSI.php - you put that code in your homepage instead. (Never, ever modify SSI.php for display purposes only.)

You didn't specify the above, but that's easy enough to change. Use this code in your homepage. Since I have no idea what shade of blue you mean (and there are thousands of combinations) I'll simply list it as blue then you can change it later.


<?php
require('forum/SSI.php'); // or whatever the path is to it
$posts ssi_recentPosts($num_recent 8$exclude_boards null$include_boards null$output_method 'array');
echo 
'
<table border="0" class="ssi_table">'
;
foreach (
$posts as $post)
echo '
<tr>
<td valign="top">
<span style="color:blue;">'
$post['poster']['name'], '</span> : <a href="'$post['href'], '">'$post['subject'], '</a> - '$post['time'], '
</td>
</tr>'
;
echo 
'
</table>'
;

?>

bugzy

Hey Arantor I'm getting the same error. I already restore the original SSI and put your code on my home page but I'm still getting this error:

QuotePlease don't access SSI.php by URL directly; you may want to use the path ('SSI.php') or add ?ssi_function=something.
Fatal error: Call to undefined function ssi_recentposts() in /home/sample/public_html/mywebsite.com/wp-content/themes/sports/home.php on line 29


on the first line of your code I put the path like this

require('http://www.mywebsite.com/forum/SSI.php'); // or whatever the path is to it

Is that right? Becuase I'm still getting the error..

bugzy

btw what will happen if I edit some part of the ssi?

Arantor

Quote from: bugzy on July 17, 2009, 03:43:33 AM
require('http://www.mywebsite.com/forum/SSI.php'); // or whatever the path is to it

Is that right? Becuase I'm still getting the error..

No, that's wrong. You don't give require() a full URL, you give it a path to the relevant file.

Judging by your error message, I think you want to add:

require('/home/sample/public_html/mywebsite.com/forum/SSI.php');



If you do edit some part of the SSI, you may well break future upgrades, not to mention if you have to do a full reinstall later you'll have to remodify the code.

bugzy

Arantor I already change the path. But I have this error now

QuoteFatal error: Cannot redeclare is_admin() (previously declared in /home/sample/public_html/mywebsite.com/wp-includes/query.php:100) in /home/sample/public_html/mywebsite.com/forum/Sources/Security.php on line 839

Arantor

Ah, yes, you're adding WordPress and SMF 1.1 together, I should have noticed sooner.

Edit forum/Sources/Security.php - at the bottom you'll find a function called is_admin(). Rename that to smf_admin(). As per the comments in the notes it is a legacy function and isn't used elsewhere in SMF (and shouldn't be in any mods, either)

bugzy

There you go! Perfect!

Thanks again Arantor! :)

bugzy

Arantor one last request how can I make the poster in bold? Thanks!

Arantor

Just change this bit (only):
<span style="color:blue;">', $post['poster']['name'], '</span>

Into:
<b><span style="color:blue;">', $post['poster']['name'], '</span></b>


bugzy

Arantor I noticed some error.. When I tried it to my desktop where I log-in to the forum there's no error. And then when I test it to my laptop where I didn't login on the forum I got this error:


QuoteNotice: SSI.php was unable to load a session! This may cause problems with logout and other functions - please make sure SSI.php is included before *anything* else in all your scripts! in /home/sampe/public_html/mywebsite.com/forum/SSI.php on line 166


I can still see the posts and there's no problem with that, but this error appeared above the posts.
What do you think?

Akyhne

The require(..ssi.php) must be the first line in your file with an opening and closing php tag.

bugzy

akyne

here's the code of my file I don't know what you mean can you edit it for me? Thanks!

[size=3]<?php get_header(); ?>

<div id="content">

<div id="homepage">

<div id="homepageleft">

<div class="featured">
<b>Breaking Sports News</b>
<img style="margin:5px 0px 10px 0px" src="<?php bloginfo('template_url'); ?>/images/hp-main.jpg" alt="Featured Story" />
<?php $recent = new WP_Query("cat=1&showposts=1"); while($recent->have_posts()) : $recent->the_post();?><b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>

<?php the_content_limit(125"Read more &raquo;"); ?><div style="clear:both;"></div>
<?php endwhile; ?>
</div>

<div class="newsletter">
<b>eNews &amp; Updates</b>
<p>Sign up to receive the latest breaking news, as well as all of your other favorite headlines!</p><form action="http://www.feedburner.com/fb/a/emailverify" method="post" target="popupwindow" onsubmit="window.open('http://www.feedburner.com', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true"><p><input type="text" value="Enter your email address..." id="s2" onfocus="if (this.value == 'Enter your email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your email address...';}" name="email"/><input type="hidden" value="http://feeds.feedburner.com/~e?ffid=FEEDBURNERID" name="url"/><input type="hidden" value="eNews Subscribe" name="title"/><input type="submit" value="GO" id="sbutt2" /></p></form>
</div>

<div style="clear:both;"></div>

<h2>LATEST POSTS FROM THE FORUM</h2>
       
      [b]  <?php
require('/home/boxed04/public_html/hoopsground.com/forum/SSI.php'); // or whatever the path is to it
$posts ssi_recentPosts($num_recent 8$exclude_boards null$include_boards null$output_method 'array');
echo 
'
   <table border="0" class="ssi_table">'
;
foreach (
$posts as $post)
   echo 
'
      <tr>
         <td valign="top">
            <b><span style="color:blue;">'
$post['poster']['name'], '</span></b> :   <a href="'$post['href'], '">'$post['subject'], '</a> - '$post['time'], '
         </td>
      </tr>'
;
echo 
'
   </table>'
;

?>

[/b]

</div>

<div id="homepageright">

<h2>Headlines</h2>

<?php $recent = new WP_Query("cat=1&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
<b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
<?php the_content_limit(130""); ?>

<div class="hppostmeta">
<p><?php the_time('F j, Y'); ?> | <a href="<?php the_permalink() ?>" rel="bookmark">Read the story &raquo;</a></p>
</div>

<?php endwhile; ?><br />

<h2>Featured Video</h2>
               
               

<br />

<h2>Advertisement</h2>

           
               <br />


             

</div>





</div>

<?php include(TEMPLATEPATH."/sidebar.php");?>

</div>

<!-- The main column ends  -->

<?php get_footer(); ?>[/size]

Akyhne

I'm not sure this will even help, as your file is not a complete HTML file. It misses a doc declaration etc. But basically the line require('/home/boxed04/public_html/hoopsground.com/forum/SSI.php'); // or whatever the path is to it should be moved to the top and put in php tags.
Is this file part of another file with an include(); or similar?

<?php 
require('/home/boxed04/public_html/hoopsground.com/forum/SSI.php'); // or whatever the path is to it
?>

[size=3]<?php get_header(); ?>

<div id="content">

<div id="homepage">

<div id="homepageleft">

<div class="featured">
<b>Breaking Sports News</b>
<img style="margin:5px 0px 10px 0px" src="<?php bloginfo('template_url'); ?>/images/hp-main.jpg" alt="Featured Story" />
<?php $recent = new WP_Query("cat=1&showposts=1"); while($recent->have_posts()) : $recent->the_post();?><b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>

<?php the_content_limit(125"Read more &raquo;"); ?><div style="clear:both;"></div>
<?php endwhile; ?>
</div>

<div class="newsletter">
<b>eNews &amp; Updates</b>
<p>Sign up to receive the latest breaking news, as well as all of your other favorite headlines!</p><form action="http://www.feedburner.com/fb/a/emailverify" method="post" target="popupwindow" onsubmit="window.open('http://www.feedburner.com', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true"><p><input type="text" value="Enter your email address..." id="s2" onfocus="if (this.value == 'Enter your email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your email address...';}" name="email"/><input type="hidden" value="http://feeds.feedburner.com/~e?ffid=FEEDBURNERID" name="url"/><input type="hidden" value="eNews Subscribe" name="title"/><input type="submit" value="GO" id="sbutt2" /></p></form>
</div>

<div style="clear:both;"></div>

<h2>LATEST POSTS FROM THE FORUM</h2>
       
      [b]  <?php

$posts 
ssi_recentPosts($num_recent 8$exclude_boards null$include_boards null$output_method 'array');
echo 
'
   <table border="0" class="ssi_table">'
;
foreach (
$posts as $post)
   echo 
'
      <tr>
         <td valign="top">
            <b><span style="color:blue;">'
$post['poster']['name'], '</span></b> :   <a href="'$post['href'], '">'$post['subject'], '</a> - '$post['time'], '
         </td>
      </tr>'
;
echo 
'
   </table>'
;

?>

[/b]

</div>

<div id="homepageright">

<h2>Headlines</h2>

<?php $recent = new WP_Query("cat=1&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
<b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
<?php the_content_limit(130""); ?>

<div class="hppostmeta">
<p><?php the_time('F j, Y'); ?> | <a href="<?php the_permalink() ?>" rel="bookmark">Read the story &raquo;</a></p>
</div>

<?php endwhile; ?><br />

<h2>Featured Video</h2>
               
               

<br />

<h2>Advertisement</h2>

           
               <br />


             

</div>





</div>

<?php include(TEMPLATEPATH."/sidebar.php");?>

</div>

<!-- The main column ends  -->

<?php get_footer(); ?>[/size]

bugzy

Thanks Akyhne!

Error is gone now.. Hmm can we make the name of the thread underlined? w/out using css? Thanks!

Advertisement: