Last Posts/Topics Code Not Working Quite Right

Discussion forum for MOD Writers regarding MOD Development.
Locked
Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve
Contact:

Last Posts/Topics Code Not Working Quite Right

Post by Pony99CA » Tue Feb 23, 2010 10:16 am

I created my own versions of the code to show Last Posts and Last Topics based on the How to display posts and topics on external pages blog post. You can see my code on my board. It works well except for two problems:
  • The pages aren't styled correctly. There's no header or footer and the page title is wrong.
  • Viewing the pages logs me out of the board and I have to log back in.
I'm curious what I'm doing wrong as the main function seems to work perfectly.

Here are the links to the external pages:

Last 5 Topics
Last 5 Posts

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
m157y
Registered User
Posts: 482
Joined: Mon Apr 30, 2007 9:39 am
Location: Russia, Moscow, Khimki
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by m157y » Tue Feb 23, 2010 4:24 pm

Try to remove script dir from cookies path at phpBB's configuration.
Just set it to / and nothing more.
Then try
P.S.
it'll kill all logged in statuses for your board, but it'll continue work after new login.
P.P.S.
I can't reproduce it on my localhost, but you have an little problem at
lastposts.php

Code: Select all

$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode_bitfield wasn't defined before, for fixing just add before

Code: Select all

$bbcode_bitfield = $posts_row['bbcode_bitfield'];
Also your lasttopics.php contain a lot of not needed routines, i think you need to clean-up it :)

Edit: Ah, and i forgot. Please delete me from your board and provide a test account at next time.
m157y aka Misty
NO SUPPORT VIA PM
KarmaMOD for phpBB 3.0.x | bbAJAX
Follow me on twitter

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51780
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by Brf » Tue Feb 23, 2010 4:30 pm

Yes. You need to change your cookie path to "/"
With it set to "/discuss/", the cookie is not valid in the parent folder.

Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by Pony99CA » Tue Feb 23, 2010 10:10 pm

Thanks for the reply.
m157y wrote:Try to remove script dir from cookies path at phpBB's configuration.
Just set it to / and nothing more.
Then try
P.S.
it'll kill all logged in statuses for your board, but it'll continue work after new login.
So that will basically make the cookie global to my whole site? That's fine with me. I only have one other real user right now, so logging him out won't be a big deal. :D
m157y wrote:P.P.S.
I can't reproduce it on my localhost, but you have an little problem at
lastposts.php

Code: Select all

$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode_bitfield wasn't defined before, for fixing just add before

Code: Select all

$bbcode_bitfield = $posts_row['bbcode_bitfield'];
Also your lasttopics.php contain a lot of not needed routines, i think you need to clean-up it :)
You should probably let battye know about those. I pretty much took the lasttopics.php code from the blog post and lastposts.php from the site he linked to in the blog post. I think that I only changed the HTML templates and added another variable to lasttopics.php (and maybe fixed a bug and changed the SQL query a bit in one of them).

I'll look at mine, but I don't really use the code; I was just showing that other user on my board that it could be made to work. I was just curious why these things were happening.
m157y wrote:Edit: Ah, and i forgot. Please delete me from your board and provide a test account at next time.
I thought seeing the code would be sufficient; I didn't expect that you'd need to log in. Sorry for the bad assumption. Your account has been deleted.

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by Pony99CA » Tue Feb 23, 2010 10:37 pm

Brf wrote:Yes. You need to change your cookie path to "/"
With it set to "/discuss/", the cookie is not valid in the parent folder.
As m157y and you agreed, I did as you suggested and changed the cookie path to "/". I also cleared all board cookies to get rid of the old ones.

Now when I log in, it says that I have successfully logged in, but when I get redirected to the Board Index, I'm logged out again. :? And, as I can't log in, I can't get into the ACP to try to fix things.

I'm using IE 7 (the only browser I have here) and even tried deleting all of my cookies from the Internet Options dialog. Still no luck....

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
3Di
Former Team Member
Posts: 13914
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by 3Di » Tue Feb 23, 2010 10:39 pm

use phpmyadmin or a similar tool to restore your cookie settings, in the meanwhile..
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by Pony99CA » Tue Feb 23, 2010 10:53 pm

3Di wrote:use phpmyadmin or a similar tool to restore your cookie settings, in the meanwhile..
I just tried a different PC and was able to log in. And, even better, linking to those scripts no longer logs me out. :)

I assume the browser that I had open cached something (session, session cookies, whatever) which prevented me from logging on from that machine again (even after opening another browser window). I presume that closing all of my browser windows will fix the issue, but I can't do that right now.

So now that the second problem is probably fixed, what about the first one? Why aren't the page headers and footers displaying on those pages?

Thanks,
Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
3Di
Former Team Member
Posts: 13914
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by 3Di » Tue Feb 23, 2010 11:00 pm

Pony99CA wrote:So now that the second problem is probably fixed, what about the first one? Why aren't the page headers and footers displaying on those pages?
in your html you need to 'include' both overall_header and overall_footer.htmls .. at the beginning and the bottom. I guess. On the fly. Have a look to the other .html files.
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

User avatar
m157y
Registered User
Posts: 482
Joined: Mon Apr 30, 2007 9:39 am
Location: Russia, Moscow, Khimki
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by m157y » Tue Feb 23, 2010 11:24 pm

Oh, sorry me, i missed second problem.
just add at your template files
at top

Code: Select all

<!-- INCLUDE overall_header.html -->
at bottom

Code: Select all

<!-- INCLUDE overall_footer.html -->
m157y aka Misty
NO SUPPORT VIA PM
KarmaMOD for phpBB 3.0.x | bbAJAX
Follow me on twitter

Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by Pony99CA » Wed Feb 24, 2010 6:00 am

m157y wrote:Oh, sorry me, i missed second problem.
just add at your template files
at top

Code: Select all

<!-- INCLUDE overall_header.html -->
at bottom

Code: Select all

<!-- INCLUDE overall_footer.html -->
Thanks to 3Di and you for that tip. I thought the calls to page_header and page_footer would include those files. I have to wonder why battye didn't mention those includes at all, either in his original blog post or his later blog post. :? I suppose if you want those items embedded in another page, you wouldn't want the page_header and page_footer calls.

Anyway, things are looking good now. The font's a little small, the block quotes in the last posts have text overlapping with the quotation marks and the list numbers in the last topics break the margin, but some CSS should clean that up.

Thanks again,
Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51780
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by Brf » Wed Feb 24, 2010 12:22 pm

Pony99CA wrote: I have to wonder why battye didn't mention those includes at all, either in his original blog post or his later blog post. :? I suppose if you want those items embedded in another page, you wouldn't want the page_header and page_footer calls.
That is correct. That article assumes you are embedding the topics into an external page with a different layout. The http://www.phpbb.com/kb/article/add-a-n ... -to-phpbb/ article shows you that you need the header and footer includes.

Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by Pony99CA » Fri Feb 26, 2010 12:21 am

Pony99CA wrote:I assume the browser that I had open cached something (session, session cookies, whatever) which prevented me from logging on from that machine again (even after opening another browser window). I presume that closing all of my browser windows will fix the issue, but I can't do that right now.
That turned out not to be the case. On my home PC, I used phpBB's Delete all board cookies function and even rebooted my PC and I still couldn't log in to my board in Firefox 3.6. I actually had to manually delete the phpBB cookies using Firefox's Tools before I could log in again.

Is that a bug in the Delete all board cookies function? If a board admin changes his cookie setting, this seems to badly break the login process even if the user used the Delete all board cookies function. How are normal users supposed to figure this out?

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by Pony99CA » Fri Feb 26, 2010 12:41 am

Brf wrote:
Pony99CA wrote: I have to wonder why battye didn't mention those includes at all, either in his original blog post or his later blog post. :? I suppose if you want those items embedded in another page, you wouldn't want the page_header and page_footer calls.
That is correct. That article assumes you are embedding the topics into an external page with a different layout. The http://www.phpbb.com/kb/article/add-a-n ... -to-phpbb/ article shows you that you need the header and footer includes.
It certainly does. I just didn't expect that given the calls to page_header and page_footer. It seems odd that they don't generate those (I haven't tried to follow that process, so it may not be technically possible or desirable), but at least I know the rules now. :)

Of course, I still wonder why he'd show calling page_header and page_footer without at least mentioning adding the includes of overall_header.html and overall_footer.html. Would calling those functions be useful in any other context where you weren't including the templates?

Thanks,
Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51780
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by Brf » Fri Feb 26, 2010 12:14 pm

The page_header does the initial "header:" and fills in a bunch of template variables.
The page_footer generates the debug variables, initiates the template 'body' call and cron, and call-exits the script.

I suppose neither is required if you do not need any of the variables, as long as you

Code: Select all

$template->display('body');
manually.

User avatar
m157y
Registered User
Posts: 482
Joined: Mon Apr 30, 2007 9:39 am
Location: Russia, Moscow, Khimki
Contact:

Re: Last Posts/Topics Code Not Working Quite Right

Post by m157y » Fri Feb 26, 2010 1:09 pm

but if you plan don't use page_footer(); i think it'll be good if you'll call garbage_collection();. Because it's unloading cache(which was loaded on session init) and also it'll close connection to db, which was initiated at common.php.
m157y aka Misty
NO SUPPORT VIA PM
KarmaMOD for phpBB 3.0.x | bbAJAX
Follow me on twitter

Locked

Return to “[3.0.x] MOD Writers Discussion”