phpBB SEO
Boards
Directory  
SEO  
Downloads
  phpBB SEO : Search Engine Optimization, Directory, Forums  
Index
Forums
Annuaire
Référencement
Télécharger
 
  Search Rechercher
    Register
Username :  Password :  Log me on automatically each visit  
S'enregistrer  
 
   
mod Rewrite and phpbb fetchall (display poll)

 
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB mod Rewrite
::  
Author Message
HB.
PR0
PR0


Joined: 26 Oct 2006
Posts: 62

mod Rewrite and phpbb fetchall (display poll)Posted: Tue Apr 17, 2007 4:34 pm    Post subject: mod Rewrite and phpbb fetchall (display poll)

Hello,

I ran a search on using the keyword "fetchall" and came up with a somewhat close result. I currently have mod rewrite installed on my forum, and now I have started to create a website around my forum. I'm using phpbb fetchall to pull certain data from the forum, and display on my home page. I'm trying to pull the Polls data but the fetchall script uses the standard phpbb urls while of course mod Rewrite changes them. I believe this is why I'm getting a blank area where the poll should be, but on another test site using a vanilla phpbb forum the poll displays. I would be thankful for your help, here is the code from the poll section

Code:

<!-- POLL -->
<?php if (isset($poll)) { ?>
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
  <tr>
    <td class="catHead" height="28"><span class="cattitle"><?php echo $lang['Poll_question']; ?></span></td>
  </tr>
  <tr>
    <td class="row1" align="center" width="100%">
<?php if (!$poll) { ?>
<span class="gensmall"><b>No poll at the moment.</b></span>

<?php } else { ?>
<span class="gensmall"><b><?php echo $poll['vote_text']; ?></b></span>
</font>
<form method="post" action="<?php echo append_sid($phpbb_root_path . 'posting.php?t=' . $poll['topic_id']); ?>">
<table>
<?php for ($i = 0; $i < count($poll['options']); $i++) { ?>
<tr>
<td>
<input type="radio" name="vote_id" value="<?php echo $poll['options'][$i]['vote_option_id']; ?>">
</td>
<td>
<span class="gensmall"><?php echo $poll['options'][$i]['vote_option_text']; ?></span>
</td>
<td nowrap="nowrap">
<span class="gensmall">[&nbsp;<?php echo $poll['options'][$i]['vote_result']; ?>&nbsp;]</span>
</td>
</tr>
<?php } ?>
</table>
<?php if ($userdata['session_logged_in']) { ?>
<input type="submit" class="mainoption" name="submit" value="<?php echo $lang['Submit_vote']; ?>">
<input type="hidden" name="topic_id" value="<?php echo $poll['topic_id']; ?>">
<input type="hidden" name="mode" value="vote">
<?php } else { ?>
<span class="gensmall"><?php echo $lang['Rules_vote_cannot']; ?></span>
<?php } ?>
<br />
<span class="gensmall"><a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $poll['topic_id'] . '&amp;vote=viewresult'); ?>"><?php echo $lang['View_results']; ?></a></span>
</form>
<?php } ?>
    </td>
  </tr>
</table>
<br />
<?php } ?>
<!-- POLL -->
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13354

mod Rewrite and phpbb fetchall (display poll)Posted: Wed Apr 18, 2007 7:50 pm    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

This mods dos not output a topic link, but a view poll result link.

You could mod it slightly to output the topic title instead, would not make big difference for user who would still be able to view the poll results from the topic.
And then have the link rewritten, but, from the piece of code you posted, I cannot tell if the topic title is available for url injection.

The link as is is using $lang['View_results'] instead.
So we need to find out where the SQL query is performed to build the $poll array, and make sure topic title is queried from here and then do the rewrite trick.

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
HB.
PR0
PR0


Joined: 26 Oct 2006
Posts: 62

mod Rewrite and phpbb fetchall (display poll)Posted: Wed Apr 18, 2007 9:33 pm    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

Ok thanks for the reply, here is a copy of the entire mod, well at least the portal.php. I'm just taking bits and pieces from it for example the profile section, the login section, and the poll. I later intend on adding the smartor album snipt of code, but I don't think I have mod-rewrite setup for the album.

[mod]Was not in this one, could you preferably post links to ZIP archive instead, to much code kills code Wink[/mod]
Back to top
HB.
PR0
PR0


Joined: 26 Oct 2006
Posts: 62

mod Rewrite and phpbb fetchall (display poll)Posted: Wed Apr 18, 2007 9:34 pm    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

Here is the poll.php, but I don't think you'll need it.

Code:
<?php
###############################################################################
##                                                                           ##
## phpBB Fetch All - A modification to phpBB that displays data from the     ##
##                   forum on any page of a website.                         ##
## ------------------------------------------------------------------------- ##
## This module contains functions for fetching poll related data.            ##
##                                                                           ##
###############################################################################
##                                                                           ##
## Authors: Volker 'Ca5ey' Rattel <webmaster@phpbbfetchall.com>              ##
##          http://www.phpbbfetchall.com/                                    ##
##                                                                           ##
## This file is free software; you can redistribute it and/or modify it      ##
## under the terms of the GNU General Public License as published  by the    ##
## Free Software Foundation; either version 2, or (at your option) any later ##
## version.                                                                  ##
##                                                                           ##
## This file is distributed in the hope that it will be useful, but WITHOUT  ##
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     ##
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for  ##
## more details.                                                             ##
##                                                                           ##
###############################################################################

###############################################################################
## NO CHANGES NEEDED BELOW
###############################################################################

//
// prevent hacking attempt
//

if (!defined('IN_PHPBB'))
{
   die('hacking attempt');
}

###############################################################################
##                                                                           ##
## phpbb_fetch_poll()                                                        ##
## ------------------------------------------------------------------------- ##
## Fetches a poll and the vote results. You can specify the forum from which ##
## the poll will be fetched. If auth_check is enabled the the poll will be   ##
## checked against the user permissions.                                     ##
##                                                                           ##
## PARAMETER                                                                 ##
##                                                                           ##
##     forum_id                                                              ##
##                                                                           ##
##         this can be either null to fetch the latest poll from the whole   ##
##         board like                                                        ##
##                                                                           ##
##             $poll = phpbb_fetch_poll();                                   ##
##                                                                           ##
##         or you can specify a single forum with                            ##
##                                                                           ##
##             $poll = phpbb_fetch_poll(1);                                  ##
##                                                                           ##
##         or - finally - you can specify a list of forums with              ##
##                                                                           ##
##             $poll = phpbb_fetch_poll(array(1, 2, 3));                     ##
##                                                                           ##
## EXAMPLE                                                                   ##
##                                                                           ##
##     $poll = phpbb_fetch_poll();                                           ##
##                                                                           ##
##     if ($poll)                                                            ##
##     {                                                                     ##
##         echo $poll['vote_text'];                                          ##
##         echo '<form method="post" action="' . $phpbb_root_path;           ##
##         echo 'posting.php?t=' . $poll['topic_id'] . '">';                 ##
##         for ($i = 0; $i < count($poll['options']); $i++)                  ##
##         {                                                                 ##
##             echo '<input type="radio" name="vote_id" value="';            ##
##             echo $poll['options'][$i]['vote_option_id'] . '">';           ##
##             echo $poll['options'][$i]['vote_option_text'];                ##
##             echo '<br>';                                                  ##
##         }                                                                 ##
##         echo '<input type="hidden" name="topic_id" value="';              ##
##         echo $poll['topic_id'] . '">';                                    ##
##         echo '<input type="hidden" name="mode" value="vote">';            ##
##         echo '<input type="submit" name="submit" value="Vote">';          ##
##     }                                                                     ##
##                                                                           ##
###############################################################################

function phpbb_fetch_poll($forum_id = null)
{
   global $CFG;

   //
   // create a list of forums with read permission
   // (only takes action when auth_check is enabled)
   //

   phpbb_get_auth_list();

   //
   // determine the forum list based on the user input
   // and/or permissions (depends on auth check)
   //

   $forum_list = phpbb_get_forum_list($forum_id);

   //
   // if read permissions do not allow us to fetch anything
   // we return nicely
   //

   if (!$forum_list and $CFG['auth_check'])
   {
      return;
   }

   $sql = 'SELECT f.*, p.*, pt.*, t.*, u.*, vd.*
            FROM ' . TOPICS_TABLE     . ' AS t,
                ' . USERS_TABLE      . ' AS u,
                ' . POSTS_TEXT_TABLE . ' AS pt,
                ' . POSTS_TABLE      . ' AS p,
                ' . FORUMS_TABLE     . ' AS f,
                ' . VOTE_DESC_TABLE  . ' AS vd
            WHERE t.topic_poster = u.user_id
               AND t.topic_first_post_id = pt.post_id
               AND t.topic_first_post_id = p.post_id
               AND t.topic_status <> 1
               AND t.topic_status <> 2
               AND t.topic_vote = 1
               AND t.forum_id = f.forum_id
               AND t.topic_id = vd.topic_id';

   if ($forum_list)
   {
      $sql .= '
               AND t.forum_id IN (' . $forum_list . ')';
   }

   $sql .= '
            ORDER BY p.post_time DESC
            LIMIT 0,1';

   $result = phpbb_fetch_row($sql);

   if ($result)
   {
      $sql = 'SELECT *
               FROM ' . VOTE_RESULTS_TABLE . '
               WHERE vote_id = ' . $result['vote_id'] . '
               ORDER BY vote_option_id';

      $result['options'] = phpbb_fetch_rows($sql);
   }

   return $result;
} // end func phpbb_fetch_poll

###############################################################################
##                                                                           ##
## phpbb_fetch_poll_bt()                                                     ##
## ------------------------------------------------------------------------- ##
## Fetches a poll and the vote results. You can specify the topic id from    ##
## which the poll will be fetched. Thanks to abravorus.                      ##
##                                                                           ##
## PARAMETER                                                                 ##
##                                                                           ##
##     topic_id                                                              ##
##                                                                           ##
##         a single topic id                                                 ##
##                                                                           ##
## EXAMPLE                                                                   ##
##                                                                           ##
##     $poll = phpbb_fetch_poll_bt(1);                                       ##
##                                                                           ##
##     if ($poll)                                                            ##
##     {                                                                     ##
##         echo $poll['vote_text'];                                          ##
##         echo '<form method="post" action="' . $phpbb_root_path;           ##
##         echo 'posting.php?t=' . $poll['topic_id'] . '">';                 ##
##         for ($i = 0; $i < count($poll['options']); $i++)                  ##
##         {                                                                 ##
##             echo '<input type="radio" name="vote_id" value="';            ##
##             echo $poll['options'][$i]['vote_option_id'] . '">';           ##
##             echo $poll['options'][$i]['vote_option_text'];                ##
##             echo '<br>';                                                  ##
##         }                                                                 ##
##         echo '<input type="hidden" name="topic_id" value="';              ##
##         echo $poll['topic_id'] . '">';                                    ##
##         echo '<input type="hidden" name="mode" value="vote">';            ##
##         echo '<input type="submit" name="submit" value="Vote">';          ##
##     }                                                                     ##
##                                                                           ##
###############################################################################

function phpbb_fetch_poll_bt($topic_id = null)
{
   global $CFG;

   if (!isset($topic_id))
   {
      return;
   }

   $sql = 'SELECT f.*, p.*, pt.*, t.*, u.*, vd.*
            FROM ' . TOPICS_TABLE     . ' AS t,
                ' . USERS_TABLE      . ' AS u,
                ' . POSTS_TEXT_TABLE . ' AS pt,
                ' . POSTS_TABLE      . ' AS p,
                ' . FORUMS_TABLE     . ' AS f,
                ' . VOTE_DESC_TABLE  . ' AS vd
            WHERE vd.topic_id = ' . $topic_id . '
               AND t.topic_poster = u.user_id
               AND t.topic_first_post_id = pt.post_id
               AND t.topic_first_post_id = p.post_id
               AND t.topic_status <> 1
               AND t.topic_status <> 2
               AND t.topic_vote = 1
               AND t.forum_id = f.forum_id
               AND t.topic_id = vd.topic_id';

   $sql .= '
            ORDER BY p.post_time DESC
            LIMIT 0,1';

   $result = phpbb_fetch_row($sql);

   if ($result)
   {
      //
      // perform an auth check if requested
      //

      if ($CFG['auth_check'])
      {
         phpbb_get_auth_list();

         if (!in_array($result['forum_id'], $CFG['auth_list']))
         {
            return;
         }
      }

      $sql = 'SELECT *
               FROM ' . VOTE_RESULTS_TABLE . '
               WHERE vote_id = ' . $result['vote_id'] . '
               ORDER BY vote_option_id';

       $result['options'] = phpbb_fetch_rows($sql);
   }

   return $result;
} // end func phpbb_fetch_poll_bt

###############################################################################
##                                                                           ##
## phpbb_fetch_poll_voters()                                                 ##
## ------------------------------------------------------------------------- ##
## Fetches all users who voted for the given poll.                           ##
##                                                                           ##
## PARAMETER                                                                 ##
##                                                                           ##
##     vote_id                                                               ##
##                                                                           ##
##         a single vote id                                                  ##
##                                                                           ##
## EXAMPLE                                                                   ##
##                                                                           ##
##     $voted  = false;                                                      ##
##     $poll   = phpbb_fetch_poll();                                         ##
##     $voters = phpbb_fetch_poll_voters($poll['vote_id']);                  ##
##                                                                           ##
##     for ($i = 0; $i < count($voters); $i++)                               ##
##     {                                                                     ##
##         if ($voters[$i]['vote_user_id'] == $userdata['user_id'])          ##
##         {                                                                 ##
##             $voted = true;                                                ##
##         }                                                                 ##
##     }                                                                     ##
##                                                                           ##
##     echo $voted ? 'true' : 'false';                                       ##
##                                                                           ##
###############################################################################

function phpbb_fetch_poll_voters($vote_id = null)
{
   if ($vote_id and !intval($vote_id))
   {
      phpbb_raise_error('Vote ID must be a numeric value.',
         __FILE__, __LINE__);
   }

   $sql = 'SELECT * FROM ' . VOTE_USERS_TABLE . '
      WHERE vote_id = ' . $vote_id . '
      ORDER BY vote_user_id';

   $result = phpbb_fetch_rows($sql);

   return $result;
} // end func phpbb_fetch_poll_voters

?>
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13354

mod Rewrite and phpbb fetchall (display poll)Posted: Thu Apr 19, 2007 8:15 am    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

All right, so it's doable Wink

In you first code snipet, the one outputting links, find :

Code:
<span class="gensmall"><a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $poll['topic_id'] . '&amp;vote=viewresult'); ?>"><?php echo $lang['View_results']; ?></a></span>


Replace with :
Code:
<?php
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$phpbb_seo->seo_url['topic'][$poll['topic_id']] = $phpbb_seo->format_url($poll['topic_id']);
// www.phpBB-SEO.com SEO TOOLKIT END
?>
<span class="gensmall"><a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $poll['topic_id']); ?>"><?php echo $poll['topic_title']; ?></a></span>


Should do it.

If not, we'll grab title from the poll function, since they are grabbed from there.

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
HB.
PR0
PR0


Joined: 26 Oct 2006
Posts: 62

mod Rewrite and phpbb fetchall (display poll)Posted: Thu Apr 19, 2007 9:44 am    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

hmmm...maybe we can try your second method, the poll still is not displaying.
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13354

mod Rewrite and phpbb fetchall (display poll)Posted: Thu Apr 19, 2007 9:51 am    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

What do you mean not displaying ?

I though we only had to rewrite links, assuming the mod was working, can you confirm ?

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
HB.
PR0
PR0


Joined: 26 Oct 2006
Posts: 62

mod Rewrite and phpbb fetchall (display poll)Posted: Thu Apr 19, 2007 4:46 pm    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

Well, I'm testing the code on fetchall's example portal first. Here is an example of their portal on a standard phpbb forum
http://www.forum.a1forums.com/phpbb/mods/phpbb_fetch_all/examples/portal.php

Here is an example of a forum with mod-rewrite
http://www.mysite.a1forums.com/phpbb/mods/phpbb_fetch_all/examples/portal.php

You will notice that the poll appears on the standard forum. I have also concluded the issue may be with the CH sub-forums, but the smartor portal has no problems displaying a poll http://www.mysite.a1forums.com/phpbb

I figured that the poll was not displaying because the fetchall code was using viewtopic.php?t= and posting.php?t= while mod-rewrite doesn't use those types of url outputs. I could totally be wrong, which is very likely.
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13354

mod Rewrite and phpbb fetchall (display poll)Posted: Fri Apr 20, 2007 7:59 am    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

So you're using CH, so it must be because you're not using 0.2.x phpBB SEO mod rewrite isn't it.

So try first to only replace :

Code:
<span class="gensmall"><a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $poll['topic_id'] . '&amp;vote=viewresult'); ?>"><?php echo $lang['View_results']; ?></a></span>

with :
Code:

<span class="gensmall"><a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $poll['topic_id']); ?>"><?php echo $poll['topic_title']; ?></a></span>


to see how it goes.

Then, with the 0.0.x versions of the phpBB SEO mod rewrite, the trick should be more like adding like before :
Code:
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_topic_name = format_url($poll['topic_id']);
// www.phpBB-SEO.com SEO TOOLKIT END


Instead of :

Code:
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$phpbb_seo->seo_url['topic'][$poll['topic_id']] = $phpbb_seo->format_url($poll['topic_id']);
// www.phpBB-SEO.com SEO TOOLKIT END


++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche


Last edited by dcz on Mon Apr 23, 2007 10:39 am; edited 1 time in total
Back to top
Visit poster's website
HB.
PR0
PR0


Joined: 26 Oct 2006
Posts: 62

mod Rewrite and phpbb fetchall (display poll)Posted: Sun Apr 22, 2007 3:28 am    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

ok, I just tried those methods, and they didn't work. So I installed the same older version of CH to see if the conflict lies within the mod, and yes it does. So I'll have to seek the answer over at their forum.
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13354

mod Rewrite and phpbb fetchall (display poll)Posted: Mon Apr 23, 2007 10:40 am    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

We really need a CH mod rewrite ... time, time time ....

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
HB.
PR0
PR0


Joined: 26 Oct 2006
Posts: 62

mod Rewrite and phpbb fetchall (display poll)Posted: Tue Apr 24, 2007 6:44 am    Post subject: Re: mod Rewrite and phpbb fetchall (display poll)

So far your CH rewrite appears to be working fine on my board, but I am using a older version of CH.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB mod Rewrite
Page 1 of 1

Navigation Similar Topics

Jump to: