G2 in Textpattern with URL Rewrite
|
paularms
![]()
Joined: 2005-05-16
Posts: 13 |
Posted: Sat, 2005-07-30 00:24
|
|
Has anyone successfully embedded G2 into Textpattern? I did a search but came up with nothing. How Textpattern works: I've used just some general php embedding, per the instructions, and tested, which works fine. With Textpattern URL Rewrite, I can access the page using both /photos/ or /index.php?s=photos and both return the same result, just the page with all image links broken. Clicking a link will just show you the main gallery page again, never showing an album or item. The problem is that I really want to use the Gallery2 URL Rewrite module, but it doesn't work out-of-the-box. So I'm going to include a little code here and hopefully it's enough to at least get on the right track towards solving my problem. Here is the Textpattern .htaccess code, which is subject to change... RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
The following is the extremely generic code that I'm using in Textpattern just for testing purposes, whether or not that matters. <?php
require_once('/obviously/modified/link/to/gallery2/embed.php');
$ret = GalleryEmbed::init(array(
'embedUri' => 'index.php?s=photos', embedPath => 'photos/', 'relativeG2Path' => '../gallery/'));
if ($ret->isError()) {
$ret->getAsHtml(); // has error details..
exit;
}
$result = GalleryEmbed::handleRequest();
GalleryEmbed::done();
if ($result['isDone']) {
exit; // G2 has already sent output (redirect or binary data)
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?php echo $result['headHtml']; ?>
</head>
<body>
<?php
echo $result['bodyHtml'];
?>
</body>
</html>
Edit... I'll be using CVS update periodically for G2 until there's a 1.0 final. Right now I'm on G2B4, aka Flippin' Sweet |
|
| Login or register to post comments |


Posts: 32509
in your textpattern .htaccess file, you'll have to add the g2 rewrite rules too.
that means:
1. browse to your g2 within textpattern,
2. click on site admin
3. click on url rewrite
4. enter the embed stuff, click save
5. go to the rules tab, click save
at this point, it will have added the g2 rewrite rules to your existing textpattern htaccess file. maybe you'll have to change the order to make it work.
Posts: 13
No matter what I try, my server is returning a "too many redirects" error.
I think the problem stems from having to first redirect /index.php and then redirect the gallery main.php
Posts: 13
Ah HA! I figured it out...
This is really the only part of the htaccess code that is needed. Ignore the rewritebase and the first set of conditions in the G2 .htaccess.
Here is the solution to my problems: photos is the section that has the G2 embed in the page template. So for the rewrite rule, we must first write to /index.php, call the section variable and then call the g2 variables. It all seems to easy now.
RewriteCond %{QUERY_STRING} view=core.DownloadItem RewriteCond %{QUERY_STRING} itemId=([0-9]+) RewriteCond %{HTTP_REFERER} !://paularmstrongdesigns\.com/ [NC] RewriteRule . /photos/main.php?g2_view=watermark.DownloadItem&g2_itemId=%1 [L] RewriteCond %{THE_REQUEST} \ /photos/([^?]+)(\?.|\ .) RewriteCond %{REQUEST_FILENAME} !main\.php RewriteRule . /index.php?s=photos&?g2_view=core.ShowItem&g2_path=%1 [QSA,L]Of note, this only seems to work with the watermark rewrite and view item rewrites, not with the view or add comments, download item, or slideshow views.
Posts: 133
!
Dude!
This is a fantastic idea, integrating txp with G2.
Posts: 36
tag for future reference