Is the only way to stylize this is through SSI? I searched and didn't find anything. I need to stylize it into this
<a href="#" target="_blank"><div id="forum"><h1>LOREM IPSUM DOLOR SIT</h1><h2>BY: FALCONHQ</h2></div></a>
Hey,
This is really easy to do. I use SSI functions all over my forum, when I get home, I will upload some of my code which will allow for easy styling. Don't style the code from the SSI.php main code though!
Quote from: Shuban on August 20, 2015, 01:09:04 PM
Hey,
This is really easy to do. I use SSI functions all over my forum, when I get home, I will upload some of my code which will allow for easy styling. Don't style the code from the SSI.php main code though!
Why not? Is it that wrong/wrong in general to change the style through SSI?
It's not wrong, but it's not good practice either. Eventually, the SSI.php file will get bloated.
Also, you may want to use the function in different areas of your website. Chances are, other parts of your website might require different styling. If you change the main function, this change will get translated everywhere you have the function embedded.
Quote from: Shuban on August 20, 2015, 01:45:44 PM
It's not wrong, but it's not good practice either. Eventually, the SSI.php file will get bloated.
Also, you may want to use the function in different areas of your website. Chances are, other parts of your website might require different styling. If you change the main function, this change will get translated everywhere you have the function embedded.
Ahh, got it. Will be waiting then. :)
yup... do not edit the SSI.php file...
instead, you call the SSI function as an array anf then output the values in the format that you want...
http://wiki.simplemachines.org/smf/Category:SSI
Quote from: Kindred on August 20, 2015, 01:49:22 PM
yup... do not edit the SSI.php file...
instead, you call the SSI function as an array anf then output the values in the format that you want...
http://wiki.simplemachines.org/smf/Category:SSI
I read them all, but I am not that good at php etc. you could say (started learning php only recently, mainly HTML/CSS), so I don't really know how to do it etc...
No problem, I was in the same boat several years ago, will update with code tomorrow!
Let's pretend you want to use the ssi_recentTopics function in its raw form, but want it styled.
Find where you want to embed the function first (this is all you). Once you've decided, use the following code:
// How many topics do you want displayed?
$count = 5;
// Replace # with the boards you want to exclude, i.e. (3,4)
$what = ssi_recentTopics($count, $exclude_boards = array(#, #), 'array');
echo'<table>';
foreach ($what as $topic)
{
echo'
<tr>
<td>
<div>
',$topic['link'],'
</div>
<div>
Cat: ', $topic['board']['link'], ' | Time: ', $topic['time'], ' | By: ', $topic['poster']['link'], '
</div>
</td>
</tr>';
}
echo'</table>';
Style as you please by putting classes or styles directly into the <div>. For example, <div style="font-weight:bold;color:red;">.
Hope this helps!
Quote from: Shuban on August 22, 2015, 12:57:18 AM
Let's pretend you want to use the ssi_recentTopics function in its raw form, but want it styled.
Find where you want to embed the function first (this is all you). Once you've decided, use the following code:
// How many topics do you want displayed?
$count = 5;
// Replace # with the boards you want to exclude, i.e. (3,4)
$what = ssi_recentTopics($count, $exclude_boards = array(#, #), 'array');
echo'<table>';
foreach ($what as $topic)
{
echo'
<tr>
<td>
<div>
',$topic['link'],'
</div>
<div>
Cat: ', $topic['board']['link'], ' | Time: ', $topic['time'], ' | By: ', $topic['poster']['link'], '
</div>
</td>
</tr>';
}
echo'</table>';
Style as you please by putting classes or styles directly into the <div>. For example, <div style="font-weight:bold;color:red;">.
Hope this helps!
Thank you! Works perfectly!! Also, just to be sure/for future etc., I want to know - is it possible to envelope the whole thing? I mean, the
',$topic['link'],'
To envelope (so the following code would be a link)
<div id="forum"><h1>LOREM IPSUM DOLOR SIT</h1><h2>BY: AIPHIRA</h2></div>
Yes, that's definitely possible.
If you'd like, you can create an id (or class) for the table, and prevent constant style reiteration (might save some space when loading the HTML).
For example:
<table id="SSI_main">
and inside your stylesheet:
#SSI_main div{font-weight: bold;}
#SSI_main div h1{text-shadow: 2px 2px #ff0000;}
Quote from: Shuban on August 22, 2015, 01:30:19 AM
Yes, that's definitely possible.
If you'd like, you can create an id (or class) for the table, and prevent constant style reiteration (might save some space when loading the HTML).
For example:
<table id="SSI_main">
and inside your stylesheet:
#SSI_main div{font-weight: bold;}
#SSI_main div h1{text-shadow: 2px 2px #ff0000;}
I don't think you understood what I asked, but somehow, I figured it out myself! xD (tried out some codes from SSI). End result for me:
$count = 5;
$what = ssi_recentTopics($count, $exclude_boards = null, 'array');
foreach ($what as $topic)
{
echo'
<a href="',$topic['href'],'">
<div id="forum">
<h1>
',$topic['subject'],'
</h1>
<h2>
By: ', $topic['poster']['name'], '
</h2>
</div>
</a>';
}
That works.
BUT, good general rule is to embed <a> inside the <div>. In other words, the div should always be the parent. But if you're content with your results, keep em.
that won't validate.... you can't validly put a div inside a link (<a>)
this is better
$count = 5;
$what = ssi_recentTopics($count, $exclude_boards = null, 'array');
foreach ($what as $topic)
{
echo'
<div id="forum">
<a href="',$topic['href'],'">
<h1>',$topic['subject'],'</h1>
<h2>By: ', $topic['poster']['name'], '</h2>
</a>
</div>';
}
but even that is problematic... you will have multiple H1 tags on your page with this -- that is BAD, as far as search engines are concerned.
this is even better
$count = 5;
$what = ssi_recentTopics($count, $exclude_boards = null, 'array');
foreach ($what as $topic)
{
echo'
<div id="topic_list">
<a href="',$topic['href'],'" class="topics">
<span class="subject">',$topic['subject'],'</span>
<span class="author">By: ', $topic['poster']['name'], '</span>
</a>
</div>';
}
and then in CSS define
.topiclist { ... }
#topics { ... }
#subject { ... }
#author { ... }
If it's a class, it should be .subject, .topics, etc. You've got it mixed up. And if it's an ID, it should have the pound sign (#).
Oops.. right you are. That's what i get for typing while sleepy :-\