| :: |
| Author |
Message |
Steve06
Joined: 18 Mar 2008 Posts: 13
|
Posted: Tue Mar 25, 2008 1:29 pm Post subject: How to generate rewritten forum URLs for my own pages? |
|
|
Hi,
I installed the advanced SEO on my forum unicp.de/forum and it seems to work well.
Now I wonder how I can generate the correct (and unique) links myself for some of the latest posts. I use this function on the front page of my site unicp.de.
Can you give me a hint, what functions of the phpbbSEO library I have to use to generate the correct URLs while respecting all the rules specified in the ACP?
Thank you for your support.
Steve |
|
|
| Back to top |
|
 |
|
 |
GoBieN
Joined: 10 Mar 2008 Posts: 39
|
Posted: Tue Mar 25, 2008 5:35 pm Post subject: Re: How to generate rewritten forum URLs for my own pages? |
|
|
If you use the zero-dupe extension, all oiginal URL's like viewtopic.php are redirected to the correct SEO link.
Otherwise i think if you just make sure you use append_sid(.....) for generating the URL's they will be changed by the SEO mod.
For own created pages not default to phpBB (like i have) i use just a custom rewrite rule and adjusted the links to the files. |
|
|
| Back to top |
|
 |
Steve06
Joined: 18 Mar 2008 Posts: 13
|
Posted: Tue Mar 25, 2008 9:23 pm Post subject: Call for more replies |
|
|
I think the correct URLs are stored in phpbb-seo's cache folder?
I need to generate for my own pages the correct and unique URLs, exactly the same that phpbb-seo uses inside the forum.
Can someone please give me a hint? |
|
|
| Back to top |
|
 |
GoBieN
Joined: 10 Mar 2008 Posts: 39
|
Posted: Tue Mar 25, 2008 10:23 pm Post subject: Re: Call for more replies |
|
|
| Steve06 wrote: | I think the correct URLs are stored in phpbb-seo's cache folder?
I need to generate for my own pages the correct and unique URLs, exactly the same that phpbb-seo uses inside the forum.
Can someone please give me a hint? |
I THINK that if you use append_sid() for generating the URL's the SEO mod will convert them.
i believe the SEO-MOD has a hook in append_sid()
This next line is an example code that the SEO mod uses to generate URL's to the latest topic.
| Code: | | append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $forum_id . '&t=' . $topic_id . '&view=unread') . '#unread' ; |
another
| Code: | | append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $forum_id . '&t=' . $topic_id . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'] ; |
If you follow this example i believe you will get your SEO url's |
|
|
| Back to top |
|
 |
Steve06
Joined: 18 Mar 2008 Posts: 13
|
Posted: Wed Mar 26, 2008 3:46 pm Post subject: it's not that easy |
|
|
your hint alone doesn't work out, I need more support:
what phpbb-files do you have to include in your script?
append_sid is part of includes/functions.php
including this alone doesn't do the job, i tried it: Notthings happens, because at the beginning of that file it says
| Code: |
if (!defined('IN_PHPBB'))
{
exit;
}
|
So what other files do I have to include to be "in phpbb"?
Thanks,
Steve[/code] |
|
|
| Back to top |
|
 |
GoBieN
Joined: 10 Mar 2008 Posts: 39
|
Posted: Wed Mar 26, 2008 5:41 pm Post subject: Re: it's not that easy |
|
|
| Steve06 wrote: | your hint alone doesn't work out, I need more support:
what phpbb-files do you have to include in your script?
append_sid is part of includes/functions.php
including this alone doesn't do the job, i tried it: Notthings happens, because at the beginning of that file it says
| Code: |
if (!defined('IN_PHPBB'))
{
exit;
}
|
So what other files do I have to include to be "in phpbb"?
Thanks,
Steve[/code] |
Well i would say:
| Code: | define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data); |
But i thought you wre going to use the code in an existing phpbb file. |
|
|
| Back to top |
|
 |
Steve06
Joined: 18 Mar 2008 Posts: 13
|
Posted: Wed Mar 26, 2008 6:38 pm Post subject: Re: it's not that easy |
|
|
| GoBieN wrote: |
But i thought you wre going to use the code in an existing phpbb file. |
No, as I implied in my first post above, I need a "recent post"-feature for the front page of my website, which is not part of the forum itself.
Is your last piece of code sufficient?
Do I need to have a user session if I only want to display the titles and links of the last 10 posts? |
|
|
| Back to top |
|
 |
GoBieN
Joined: 10 Mar 2008 Posts: 39
|
Posted: Wed Mar 26, 2008 7:11 pm Post subject: Re: it's not that easy |
|
|
| Steve06 wrote: | | GoBieN wrote: |
But i thought you wre going to use the code in an existing phpbb file. |
No, as I implied in my first post above, I need a "recent post"-feature for the front page of my website, which is not part of the forum itself.
Is your last piece of code sufficient?
Do I need to have a user session if I only want to display the titles and links of the last 10 posts? |
Hmm, depends, if you just pull the data out of the database and don't check permissions on the latest topics, then you don't.
If you want to check for permissions and only show topics that the user has permission at, then ofcourse you need the sessions
If you have a working version on your frontpage now, post the php code here pls. |
|
|
| Back to top |
|
 |
Steve06
Joined: 18 Mar 2008 Posts: 13
|
Posted: Wed Mar 26, 2008 7:26 pm Post subject: Re: How to generate rewritten forum URLs for my own pages? |
|
|
I think I don't need to check permissions.
Here we go:
| Code: | ##########################################################################
##########################################################################
## ##
## PHPBB GetPosts ##
## Written and tested by: Daniel Hill ##
## Retrieve X No of posts from a PHPBB Forum ##
## ##
## Copyright © 2006 DTH-Scripts.com ##
## Support: Website: www.dth-scripts.com ##
## MSN: Homer09001@gmail.com ##
## ##
## For instructions on installing check the readme.txt file ##
## ##
## Filename: getposts.php ##
## ##
##########################################################################
##########################################################################
include "config.php3";
//include "forum/includes/functions.php";
//Displays Title: "Last X Forum Posts" above posts.
//retrieve posts from database
$a = mysql_query("SELECT * FROM $table6 ORDER BY post_time DESC LIMIT $postlimit")or die (mysql_error());
while ($row = mysql_fetch_array($a)) {
$nameid = $row['poster_id'];
$subject = $row['post_subject'];
$time = $row['post_time'];
$tid = $row['topic_id'];
$fid = $row['forum_id'];
$str = $row['post_text'];
//Get User ID
$c1 = "SELECT username FROM $table8 WHERE user_id = '$nameid'";
$c = mysql_query($c1)or die(mysql_error());
while ($row1 = mysql_fetch_array($c)) {
$name = utf8_encode($row1['username']);
//Get Category
$c1 = "SELECT * FROM $table9 WHERE forum_id=$fid AND parent_id!=0";
$c = mysql_query($c1)or die(mysql_error());
while ($row2 = mysql_fetch_array($c)){
$parid = $row2['parent_id'];
$catname = utf8_encode($row2['forum_name']);
//Get Forum
$c2 = "SELECT forum_name FROM $table9 WHERE forum_id=$parid";
$c = mysql_query($c2)or die(mysql_error());
while ($row3 = mysql_fetch_array($c)) {
$forname = utf8_encode($row3['forum_name']);
date_default_timezone_set('GMT');
$current_timestamp = "$time";
$date = date('H:i \\', $current_timestamp);
$short = utf8_encode(str_shorten(preg_replace("/\[quote.+\]/","",strip_tags($str)), $len));
$subject = utf8_encode(str_shorten($subject, $len));
echo "<b><a class=Latp href=\"$webaddress/viewtopic.php?f=$fid&t=$tid\">$subject</a> - <a class=Latp2 href=\"$webaddress/viewtopic.php?f=$fid&t=$tid\">$short</a></b><a class=Latp1 href=\"$webaddress/viewtopic.php?f=$fid&t=$tid\"> gepostet um $date</a> <br>";
}}}}
?> |
|
|
|
| Back to top |
|
 |
GoBieN
Joined: 10 Mar 2008 Posts: 39
|
Posted: Thu Mar 27, 2008 8:12 pm Post subject: Re: How to generate rewritten forum URLs for my own pages? |
|
|
| Code: | ##########################################################################
##########################################################################
## ##
## PHPBB GetPosts ##
## Written and tested by: Daniel Hill ##
## Retrieve X No of posts from a PHPBB Forum ##
## ##
## Copyright © 2006 DTH-Scripts.com ##
## Support: Website: www.dth-scripts.com ##
## MSN: Homer09001@gmail.com ##
## ##
## For instructions on installing check the readme.txt file ##
## ##
## Filename: getposts.php ##
## ##
##########################################################################
##########################################################################
include "config.php3";
//include "forum/includes/functions.php";
//Displays Title: "Last X Forum Posts" above posts.
define('IN_PHPBB', true);
$phpbb_root_path = "forum/";
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
//retrieve posts from database
$a = mysql_query("SELECT * FROM $table6 ORDER BY post_time DESC LIMIT $postlimit")or die (mysql_error());
while ($row = mysql_fetch_array($a)) {
$nameid = $row['poster_id'];
$subject = $row['post_subject'];
$time = $row['post_time'];
$tid = $row['topic_id'];
$fid = $row['forum_id'];
$str = $row['post_text'];
//Get User ID
$c1 = "SELECT username FROM $table8 WHERE user_id = '$nameid'";
$c = mysql_query($c1)or die(mysql_error());
while ($row1 = mysql_fetch_array($c)) {
$name = utf8_encode($row1['username']);
//Get Category
$c1 = "SELECT * FROM $table9 WHERE forum_id=$fid AND parent_id!=0";
$c = mysql_query($c1)or die(mysql_error());
while ($row2 = mysql_fetch_array($c)){
$parid = $row2['parent_id'];
$catname = utf8_encode($row2['forum_name']);
//Get Forum
$c2 = "SELECT forum_name FROM $table9 WHERE forum_id=$parid";
$c = mysql_query($c2)or die(mysql_error());
while ($row3 = mysql_fetch_array($c)) {
$forname = utf8_encode($row3['forum_name']);
date_default_timezone_set('GMT');
$current_timestamp = "$time";
$date = date('H:i \\', $current_timestamp);
$short = utf8_encode(str_shorten(preg_replace("/\[quote.+\]/","",strip_tags($str)), $len));
$subject = utf8_encode(str_shorten($subject, $len));
echo "<b><a class=Latp href=\"" . append_sid($webaddress . "/viewtopic.php", "f=" . $fid . "&t=" . $tid . "\">" . $subject . "</a> - <a class=Latp2 href=\"" . append_sid($webaddress . "/viewtopic.php", "f=" . $fid . "&t=" . $tid . "\">" . $short . "</a></b><a class=Latp1 href=\"" . append_sid($webaddress . "/viewtopic.php", "f=" . $fid . "&t=" . $tid . "\"> gepostet um " . $date . "</a> <br>";
}}}}
?> |
Try this ! |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13031
|
|
| Back to top |
|
 |
|
|