Is it possible to put a list of say the 5 most recent threads in a forum on the home page?
May 23, 2002, 3:46 PM
Novice (18 posts)
May 23, 2002, 3:46 PM
Post #2 of 8
Views: 5962
Well I figured out how to do this using ssi and making a separate template for forum view.
What I can't figure out is how to restrict the:
to x number of characters so the whole post is not displayed on the home page, but only the first bit.
Any ideas?
What I can't figure out is how to restrict the:
Code:
<%post_message%>to x number of characters so the whole post is not displayed on the home page, but only the first bit.
Any ideas?
May 23, 2002, 4:52 PM
User (225 posts)
May 23, 2002, 4:52 PM
Post #3 of 8
Views: 5958
Include this bit of perl:
$message = substr($message,0,50);
$message being whatever variable your message is, and 50 being how many characters to chop it off at.
Realiiity.com Forums
$message = substr($message,0,50);
$message being whatever variable your message is, and 50 being how many characters to chop it off at.
Realiiity.com Forums
May 23, 2002, 6:04 PM
Novice (18 posts)
May 23, 2002, 6:04 PM
Post #4 of 8
Views: 5934
I created a global called:
chop_message
and filled it with:
sub {
$post_message = substr($post_message,0,50);
}
Then I put the following in my template:
<div>
<%loop post_loop%>
.......
.......
<%post_subject%>
.......
.......
<%chop_message%>
<%post_message%>
.......
.......
<%endloop%>
</div>
And I get the following out put:
Unable to compile 'chop_message':
Do you have any suggetions for what I might be doing wrong?
chop_message
and filled it with:
sub {
$post_message = substr($post_message,0,50);
}
Then I put the following in my template:
<div>
<%loop post_loop%>
.......
.......
<%post_subject%>
.......
.......
<%chop_message%>
<%post_message%>
.......
.......
<%endloop%>
</div>
And I get the following out put:
Unable to compile 'chop_message':
Do you have any suggetions for what I might be doing wrong?
May 27, 2002, 12:22 AM
Veteran / Moderator (2199 posts)
May 27, 2002, 12:22 AM
Post #5 of 8
Views: 5891
You would need something like:
my $post_message = shift;
return substr($post_message,0,50);
}and then call it as <%chop_message($post_message)%> in the template.
Ivan
-----
Iyengar Yoga Resources / GT Plugins
Code:
sub { my $post_message = shift;
return substr($post_message,0,50);
}
Ivan
-----
Iyengar Yoga Resources / GT Plugins
May 31, 2002, 9:24 PM
Novice (18 posts)
May 31, 2002, 9:24 PM
Post #7 of 8
Views: 5860
Sure.
I created a separate template set so I could call it from the url, say: new_set.
then in the view_forum template for that set I deleted the enitire template and insterted something like:
<%post_loop%>
<a href="#"><%post_subject%></a>
<%post_loop%>
of course you will want to use formating appropriat to your site. In my instance I used block level CSS2, but you could use tables or what not too.
if you want to add the body of the post then you would add some thing like:
<%post_loop%>
<a href="#"><%post_subject%></a>
<p><%post_message%></p>
<%post_loop%>
I didn't end up shortening the message becaue I had to, in the end, write my own database calls to achive the controll I wanted.
however for those areas that I did use the template set I would call the forum with the folowing PHP include:
<?php include("http://www.gforum-url-goes-here.com/cgi-bin/gforum.cgi?forum=XX;t=new_set;mh=YY"); ?>
where XX = the forum id number
and YY = the number of threads to return form the fourm.
does that help?
I created a separate template set so I could call it from the url, say: new_set.
then in the view_forum template for that set I deleted the enitire template and insterted something like:
<%post_loop%>
<a href="#"><%post_subject%></a>
<%post_loop%>
of course you will want to use formating appropriat to your site. In my instance I used block level CSS2, but you could use tables or what not too.
if you want to add the body of the post then you would add some thing like:
<%post_loop%>
<a href="#"><%post_subject%></a>
<p><%post_message%></p>
<%post_loop%>
I didn't end up shortening the message becaue I had to, in the end, write my own database calls to achive the controll I wanted.
however for those areas that I did use the template set I would call the forum with the folowing PHP include:
<?php include("http://www.gforum-url-goes-here.com/cgi-bin/gforum.cgi?forum=XX;t=new_set;mh=YY"); ?>
where XX = the forum id number
and YY = the number of threads to return form the fourm.
does that help?
May 31, 2002, 9:30 PM
User (161 posts)
May 31, 2002, 9:30 PM
Post #8 of 8
Views: 5842
Yes,
Actually - I have been pluggin away at this and learning a lot in the process.
Using the mod to find the newest user as my guide, I have developed a solution that works for me.
I have put my solution in the thread for NEWEST POST - since this thread was intended for newest 5 and I have been working in parallel paths.
http://www.gossamer-threads.com/...;;page=unread#unread
Actually - I have been pluggin away at this and learning a lot in the process.
Using the mod to find the newest user as my guide, I have developed a solution that works for me.
I have put my solution in the thread for NEWEST POST - since this thread was intended for newest 5 and I have been working in parallel paths.
http://www.gossamer-threads.com/...;;page=unread#unread