[ABD] Jump to my latest post v.0.0.2

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Locked
User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

[ABD] Jump to my latest post v.0.0.2

Post by 4_seven » Mon Jun 14, 2010 4:16 pm

Jump to my latest post

MOD-Title: Jump to my latest post
MOD-Version: 0.0.2
MOD-Author: 4seven

Credits: Erik Frèrejean (for assistance to make this perfect)

Request by: cyblost
Request Thread: https://www.phpbb.com/community/viewtopi ... #p12805047

License: GNU General Public License v2

phpBB-Version: phpBB 3.0.x
phpBB-Languages: en/de*
phpBB-Styles: prosilver/subsilver2*

MOD-Description:
This Mod adds an extra icon Image Image in viewforum, where u can jump to your latest post in topic

Features:
- Jump to your latest post in each topic, where u have posted
- Jump to your latest post in each forum, where u have posted (extra ModX in contrib folder)

Main Demo: (User Guest)
https://www.4seven.de/forum/media/index.php

Demo Search Addition: (User Guest / login)
https://www.4seven.de/forum/media/index.php

Same address, but as Guest only these links are visible
View unanswered posts • View active topics

More you see as logged in user
login (un: test / pw: testuser),
go to index and click on:
View unanswered posts • View unread posts • View new posts • View active topics
or
View your posts

Download: https://www.4seven.de/forum/6test/viewtopic.php?f=3&t=73
* Download: (de/subsilver2) https://www.4seven.de/forum/6test/viewtopic.php?f=3&t=73

Search Addition v.0.0.2: (prosilver only) https://www.4seven.de/forum/6test/viewto ... p=169#p169

Image

Image

----------------------

New in v.0.0.2:
- New significant Mod Name
- Reduce too much Querys to one (thx to Erik Frèrejean)

Fix#1 for v.0.0.2
- fixing error reported by 0dd0ne
- package is updated
Last edited by 4_seven on Sun Oct 16, 2011 8:00 pm, edited 33 times in total.
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
heredia21
Registered User
Posts: 942
Joined: Sun Apr 18, 2010 6:14 pm
Contact:

Re: [DEV] View my latest Post v.0.0.1

Post by heredia21 » Mon Jun 14, 2010 5:20 pm

4_seven you keep coming out with awesome work.

When will it be available for download.
Best BlackBerry website for all users! BlackBerry News - http://blackberryempire.com

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [DEV] View my latest Post v.0.0.1

Post by 4_seven » Mon Jun 14, 2010 6:17 pm

v.0.0.1 released
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
heredia21
Registered User
Posts: 942
Joined: Sun Apr 18, 2010 6:14 pm
Contact:

Re: [DEV] View my latest Post v.0.0.1

Post by heredia21 » Mon Jun 14, 2010 7:47 pm

I followed the steps. Nothing happened. No arrow appeared.
Best BlackBerry website for all users! BlackBerry News - http://blackberryempire.com

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [DEV] View my latest Post v.0.0.1

Post by 4_seven » Mon Jun 14, 2010 7:48 pm

Check install again, clear all Board-, Style- and Browser-Cache after install and log in. Also make shure, you wrote in this topic.
Last edited by 4_seven on Mon Jun 14, 2010 7:49 pm, edited 1 time in total.
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
heredia21
Registered User
Posts: 942
Joined: Sun Apr 18, 2010 6:14 pm
Contact:

Re: [DEV] View my latest Post v.0.0.1

Post by heredia21 » Mon Jun 14, 2010 7:49 pm

Ok i got it. How can I make it so it can also appear on the index page?
Best BlackBerry website for all users! BlackBerry News - http://blackberryempire.com

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [DEV] View my latest Post v.0.0.1

Post by 4_seven » Mon Jun 14, 2010 7:51 pm

That will be a other kind of Mod.

Write a request in Mod Request Area
http://www.phpbb.com/community/viewforum.php?f=72
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
heredia21
Registered User
Posts: 942
Joined: Sun Apr 18, 2010 6:14 pm
Contact:

Re: [DEV] View my latest Post v.0.0.1

Post by heredia21 » Mon Jun 14, 2010 9:32 pm

4_seven wrote:That will be a other kind of Mod.

Write a request in Mod Request Area
http://www.phpbb.com/community/viewforum.php?f=72
Done. http://www.phpbb.com/community/viewtopi ... &t=2094486
Best BlackBerry website for all users! BlackBerry News - http://blackberryempire.com

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: [DEV] View my latest Post v.0.0.1

Post by Erik Frèrejean » Mon Jun 14, 2010 9:47 pm

I had a quick look at your code and I've noticed a couple of issues with it:

Code: Select all

AND poster_id != ' . (int) 1 . ' 
you should use the anonymous constant here, as the anonymous user can have a different ID than "1"

Code: Select all

AND poster_id != ' . ANONYMOUS . ' 
Secondly you are running the query inside a loop, which is extremely bad coding practice. This means that you run this query for every topic that is being listed. This means that when there are 25 topics (default) you are adding 25 queries to view forum. This can cause serious issues on larger boards. You really should add all the topic ids to an array and than select all the data at once, and than assign them to the block row (template::alter_block_array) <- for example
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [DEV] View my latest Post v.0.0.1

Post by 4_seven » Mon Jun 14, 2010 9:59 pm

Code: Select all

AND poster_id != ' . ANONYMOUS . '
i correct that soon
You really should add all the topic ids to an array and than select all the data at once
therefore i need a "living example" what is near to this mod, bcs. this is one of the last things i never figured out *** ;)

Code: Select all

the thing i dont know, how is the snytax here?
to output it functional to this array ***

foreach ($bla as $ blabla){

*** eg. assign_block_vars > topicrow {

'VARIABLE'   => $what syntax here? ,

 }

}
the block_vars thingie is clear
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: [DEV] View my latest Post v.0.0.1

Post by Erik Frèrejean » Mon Jun 14, 2010 10:22 pm

4_seven wrote:therefore i need a "living example" what is near to this mod, bcs. this is one of the last things i never figured out ;)
I'm writing this from the top of my head therefore I don't guaranty that this will work at the first go, but it kinda gives you an idea.

First off all lest start with changing your first MOD block in viewforum

Code: Select all

        // View my latest Post / 4seven / 2010
        $sql_latest_post = 'SELECT post_id, topic_id, forum_id
        FROM ' . POSTS_TABLE . '
        WHERE poster_id = ' . (int) $user->data['user_id'] . '
        AND poster_id != ' . (int) 1 . '        
        AND topic_id = ' . (int) $topic_id . '
        ORDER BY post_time DESC';
        $result_latest_post = $db->sql_query_limit($sql_latest_post, 1);
        $rows_latest_post   = $db->sql_fetchrowset($result_latest_post);    
        $db->sql_freeresult($result_latest_post);

        if(!isset($rows_latest_post[0]['post_id'])){
        $wrote_post  = 0;}
        else{
        $wrote_post  = $rows_latest_post[0]['post_id'];
        $wrote_topic = $rows_latest_post[0]['topic_id'];
        $wrote_forum = $rows_latest_post[0]['forum_id'];}
        // View my latest Post / 4seven / 2010     
to something that only collects the topic id from the row.

Code: Select all

if (!isset($topic_ids))
{
   $topic_ids = array();
}
$topic_ids[] = $topic_id; 
Than remove the second edit as we don't need it anymore at this point.

Code: Select all

// View my latest Post / 4seven / 2010            
            'S_WROTE_HERE'                    => ($wrote_post == 0) ? false : true,
            'U_WROTE_LINK'                    => ($wrote_post == 0) ?  '' : append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $wrote_forum . '&t=' . $wrote_topic . '&p=' . $wrote_post . '#p' . $wrote_post),
            // View my latest Post / 4seven / 2010         
Finally we're going to utilise the template engine to change the 'topicrow' block afterwards so after:

Code: Select all

        unset($rowset[$topic_id]);
    }
} 
We'll be adding the following

Code: Select all

// For non-guests only
if ($user->data['user_id'] != ANONYMOUS)
{
   // Flip $topic_ids so we know the row by topic_id
   $topic_ids = array_flip($topic_ids);

   // First collect all the data at once from the database
   $sql = 'SELECT post_id, topic_id, forum_id
      FROM ' . POSTS_TABLE . '
      WHERE poster_id = ' . $user->data['user_id'] . '
         AND ' . $db->sql_in_set('topic_id', $topic_ids) . '
      ORDER BY post_time DESC';
   $result = $db->sql_query($sql);
   // Run through the data
   while ($row = $db->sql_fetchrow($result))
   {
      $row = $topic_ids[$row['topic_id']];

      // Now add the new data to the block array
      $template->alter_block_array('topicrow', array(
         'S_WROTE_HERE' => true,
         'U_WROTE_LINK ' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&p=' . $row['post_id'] . '#p' . $row['post_id']),

      ), $row, 'change');
   }
} 
[edit]
This way you won't need the 'S_WROTE_HERE' template var anymore, because the link will only be created when there is something to display so you could check with:

Code: Select all

<!-- IF U_WROTE_LINK -->
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [DEV] View my latest Post v.0.0.1

Post by 4_seven » Mon Jun 14, 2010 10:35 pm

exact this was my major problem in "not-understanding".
how can a row (may topicrow) 'know' which row i mean with my (old style) input.
so output was confused..
i put it into the loop, bcs. i find no way to have the assignment to the rows.

>> the syntax of assignment to a rowset from an outer code before it!

i think, if i can figure it out, nothing is impossible anymore.
further i must recode some mods, that work the same way :|

big thx for teaching ...

edit: where should i put this..

Code: Select all

unset($rowset[$topic_id]);
Last edited by 4_seven on Mon Jun 14, 2010 10:47 pm, edited 1 time in total.
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: [DEV] View my latest Post v.0.0.1

Post by Erik Frèrejean » Mon Jun 14, 2010 10:46 pm

No problem, learning is one of the main tasks of this board ;).
Always remember that phpBB comes with a pretty solid framework (especially when it comes to the DBAL and the template engine), and for most common used actions you'll be able to use build in functions. Its always good to keep the sourcecode documentation at hand when MODding for phpBB. Yah its a bit outdated but most functions/methods are in there.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: [DEV] View my latest Post v.0.0.1

Post by Erik Frèrejean » Mon Jun 14, 2010 10:47 pm

4_seven wrote:edit: where exatly i put this

Code: Select all

unset($rowset[$topic_id]);
No where that is in viewforum.php itself. I've used it to define where to add the last snippet. You should paste that after the second "}" below that unset statement.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [DEV] View my latest Post v.0.0.1

Post by 4_seven » Mon Jun 14, 2010 10:49 pm

big thx again... ;)

we live and learn :geek:

-----------------

by the way @ heredia21

i figure out the show on index, but first i must recode the main-code...
Current Mods | Mod Base | php(BB) programming | No help via PM

Locked

Return to “[3.0.x] Abandoned MODs”