Mambo + Gallery - short URLS
gary_d
Joined: 2004-11-19
Posts: 26 |
Posted: Fri, 2004-11-19 23:29 |
It's possible to force Gallery to use Mambo-like SEF URL's. The following changes were done to gallery 1.5-cvs-b273, though a similar change could be back-ported to 1.4.4pl4... (this requires reasonable PHP knowledge...) In the function makeGalleryURL() (in 1.5, this is in libs/uril.php - previously it was in util.php) In the 'mambo' case for the GALLERY_EMBEDDED_INSIDE_TYPE switch... This is because mambo's SEF creation code won't touch any URL that doesn't start with 'index.php' (and, at least on my setup, mosRoot is "/".) Then, at the bottom of this function, replace: if (function_exists('sefRelToAbs') && ($args['include'] != "do_command.php") && isset($GALLERY_EMBEDDED_INSIDE) && ($GALLERY_EMBEDDED_INSIDE_TYPE == 'mambo')) { return sefRelToAbs(htmlspecialchars($url)); } else { return htmlspecialchars($url); } Simply, this just says 'if we're embedded, and embedded inside of mambo, then call mambo's function to convert the URL to a SEF one and return that... This might be a nice (and VERY SIMPLE) change which would be nice in the mainline of gallery... edit: added the conditional for function_exists()... (see below) BTW, if anyone wants to see this in action, I'm using it for my daughter's website (http://laci.garyndenise.org) along with several other SEF related changes within mambo itself (resulting in simple URLS such as "/photos/itemID/AlbumName/PhotoName") Once I figure out the "proper" way to override SEF in mambo (I keep reading there are proper hooks for this, but I can't find them), I'll put together a seperate package... Take care |
|
Posts: 26
My original code neglected to check that the sefRelToAbs() function existed before trying to call it. The embedded variables can be set, but sefRelToAbs() might not be set, when gallery is being called directly for a popup... The above code is now fixed.
Gary
Posts: 26
Another edit... some admin-type gallery links were dying (including some photo upload type things.) It's a bit harder to track those down, and they MIGHT only be related to some other SEF related changes I have on my own site (in mambo), so..
Anyway, I've fixed the above code to NOT call mambo's SEF function if gallery wants to include do_command.php. This seems to correct the problems for me....
Posts: 347
Great work, thank you very much! :D
Only one little issue. I have tested your code with Mambo 4.5.1 and Gallery v1.5-cvs-b307, when I delete a subalbum or photo in a subalbum the Gallery jumps out of Mambo.
All other admin functions are OK.
Kai
Posts: 13
Thanks for pointing me here Kai, I'm too tired to think about applying the changes at the moment (it is 4am in the morning) but just wanted to say that I noticed Gallery 1.4.4-pl2 jumped out of Mambo when renaming a nested sub-album. And that was without any modifications to either package (other than adding the gallery component), so the behaviour you noticed may not be directly attributable to the hack in this thread.
Posts: 13
Does anyone know if this feature will be incorporated into Gallery in future? Maintenance is a lot easier with less hacks.
Posts: 16
Gary_d, thanks so much for your mod here.
One question though:
In my Mambo 4.5.1a I can get the titles to reflect my Gallery 1.5rc1 album names but NOT the image names?
I tried putting all kinds of sutff in photo.header.default such as this:
The example site is at maktub.lunarpages.com
Does anyone know how to get the page titles to ALSO show the photo name when inside of Mambo?
many thanks in advance,
- Kevin
Posts: 31
I've written up a nice summary with code modifications, and a zip file with all the mods for how to get the mambo/gallery integration to use Search Engine Friendly URLs, Show the full breadcrumb path to the image you're in, and Show the correct information in the Page Title.
Posts: 16
LogicX, this will be great if I can get it work work.
I'm half way into your mod (on 4.5.2 and Gallery 1.5rc2) but I can not find the lines in the UTIL.PHP file you say to change. In fact, when I search 1.5rc2's UTIL.PHP for "mambo" it only shows up once here:
} elseif ($GALLERY_EMBEDDED_INSIDE_TYPE == 'mambo') {
And this does is not the same as the code you say to change. Is there something I'm missing or are you using a different version of Gallery other than 1.5rc2?
I'm sure the error is on my end.
Any advice (or approx line numbers to change in UTIL.PHP) would greatly appriciated.
thanks,
- Kevin
Posts: 16
Hi LogicX,
I see now where the error is. I think you meant to say "URL.PHP" instead of "UTIL.PHP" in your tutorial.
I now have most of it working (the staging URL is maktub.lunarpages.com). Can you advise on the following problems I'm having though:
1) there is an added "/" in the URL for gallery UI images. This breaks the image from appearing on screen. Thus the image and album frames break and some of the layout itself. For example:
maktub.lunarpages.com/gallery//images/pixel_trans.gif" width="1" height="1" alt="pixel_trans">
2) Uploading photos from the front end of Mambo brings up a pop up box that never loads with forms but does load my site's UI. Most important is to get the upload fields to work. But also, it'd be great if my site's UI and main nav, etc.. was not loaded into these pop up boxes since it takes up too much room.
3) I can no longer run setup after I've done this mod. I'm alays taken back my sites home page when trying to access gal/setup/index.php Is there a workaround?
thanks again,
- Kevin
Posts: 31
Thanks! I've fixed this. My previous tutorial (1.4.4 versions of gallery) had the code to be modified in util.php, not url.php. Updated.
Its not so much that there's an added slash, but that somehow its getting the image from the wrong path. The correct path would be:
maktub.lunarpages.com/gal/images/nav_next.gif
Please be sure that you have
$gallery->app->photoAlbumURL = "maktub.lunarpages.com/gal";
I believe 2 and 3 should be fixed if photoAlbumURL is correct. If this URL maps to the 'real' gallery URL, as I've tried to explain in my tutorial, then gallery will continue to function correctly for everything else.
Let me know how I can better explain the real Vs. Fake gallery URL paths.
You're welcome, keep working with me, and we'll improve upon this, and hopefully I can convince someone to put it in the next 1.5.x release of gallery ;)
Posts: 16
Logicx,
That did the trick! Thanks. I remaned my real galery name on the server but forgot to change it localy. So my updated config file was going into the wrong folder on the server. It is all working great now - UI images load, pop up windows behave great.
Can I ask one more thing? This URL is a staging URL I don't want spiders to index. Can you edit the above post and remove the http://www from my URL and the HREF?
Thanks yet once again. This mod is exactly what I was looking - meaningful page titles! :lol: :lol:
- Kevin
Posts: 16
Logicx,
One more question. Do you know how to hard code a search string into a link?
When I search the photos its returns me to the root index.php so I'm not sure what URL to use if I want to create a link that only shows pictures with certain keywords or titles.
thanks,
- Kevin
Posts: 31
Here's a search for 'mike'
Be sure to replace your Itemid with your correct one for your gallery component
http://fpux.com/index.php?option=com_gallery&Itemid=130&include=search.php&searchstring=mike
Not sure why it would return to your index page
Are you using some SEF component?
Posts: 16
Ah.. just a note for anyone else using this mod. If you re-run the config wizard at a later date be sure to add this line back into your config.php when you are done (since config wizard will remove it):
$gallery->app->embeddedphotoAlbumURL = "http:www.yourdomain/yourfakegalleryname";
Mike, the search string you sent works great. Thanks. (I'm only using Mambo core SEF.)
- Kevin
Posts: 8
I'm so frustrated. I have a feeling it has something to do with Apache, but I just can't get this to work. SEF does work if I only use the standard mambo SEF. 404sef or Aliases or anything like that has never worked for me.
According to my PHP info my host is on IIS, but an Apache API... thus confusing me because I don't know enough about it. Do I have Apache or don't I?
Anyhew.. I updated mambo and Gallery to the latest files 4.5.2 and 1.5 so I could use your zipped files (thank you for those btw). I followed instructions, but Gallery just doesn't want to cooperate with me, although the breadcrumbs seem to work, if not backwards.
It is so hard to explain, but perhaps if you visited my site http://www.ellescifiportal.com and looked through the Gallery you'd see what my issues are.
In the .htaccess file I had to close line 32 #RewriteBase / because with it open no SEF worked at all. If that gives any insight.
Thanks for any help you can give.
Jamie
Posts: 31
Perhaps you're on WINDOWS, but they're running apache.
I see what you mean by backwards crumbs -- this blows my mind, not sure how that would even be accomplished
I can't think of any reason why that line would not work, however the rest of your .htaccess seems to work, because the url: http://www.ellescifiportal.com/gallery/Sci-Fi works fine, however your gallery pages are not generating the correct SEF URL which tells me that you probably didn't replace the url.php file correctly, please check that.
no problem. Let me think about the backwards crumbs a little bit and I'll see what I can come up with.
Posts: 16
LogicX,
The Gallery RSS feed still points to the standalone gallery if you apply this mod. Is there a way for links in the RSS feed to pull up the gallery INSIDE the Mambo site? You can see my site as example here: www.maktub.com
To clarify, the RSS feed works great. But if you click a link inside your RSS reader it will take you to the standalone "gal" not the "gallery" inside mambo.
thanks,
- Kevin