Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Two textpattern instances with one image folder
It may sound weird and someone could ask “Why don´t use the MLP Plugin?”, but I am trying a different approach to a multi language setup.
For that I would like to have two different Textpattern system that share the same image folder.
So in the backend I setup the image folder for both the same. Now I would have to tell both textpatterns somehow that they should use the same table in the database to hold the images.
I had a look at include/txp_images.php already but did not really get any further. Could somebody point me in the right direction? Thought it could not be that difficult to tweak textpattern here a little bit. Or am I missing something?
It should normaly work fine if you have a folder for each language and in each folder you have one textpattern setup. If you have different authors for each language there is no point in using MLP. And you can centralize all JS and CSS as well.
What do you think?
Last edited by demoncleaner (2016-11-14 14:28:55)
Offline
Re: Two textpattern instances with one image folder
I’d be interested in that too. It is potentially useful for multi-site installations in use by the same client so that they can work from a single image pool.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Two textpattern instances with one image folder
Exactly. So let´s try to do it together. I came across this problem many times already and always ended up with either MLP or a not so elegant solution.
Would be cool if that could be done in form of a plugin. Unfortunately I am not so experienced in writing plugins and would need some help here I guess.
Basically my idea would be somethig like that:
- Install Plugin on master textpattern instance (german in my case ;-)) (choose from master/slave and use master)
- Universal table for images is created (txp_universal_images) and images are stored here from now on
- Install plugin on other textpattern instance (choose slave). txp_universal_images is used for the images from now on.
I asume here that all languages textpattern-instances are installed with a different prefix but in same DB
Does that make sense? Or is maybe less trivial then what I think?
Offline
Re: Two textpattern instances with one image folder
Sounds good in principle. Only the last assumption that all instances would use the same DB with different prefixes is not alway practicable. I appreciate that makes it easier, because only the table changes and no separate DB connection is required. But rah_swap seems able to swap to another database without messing up the rest of the site…
TXP Builders – finely-crafted code, design and txp
Offline
Re: Two textpattern instances with one image folder
As jakob says, rah_swap is probably the simplest way forward here. Just wrap it round any calls to <txp:images>
et al in your slave site’s Pages/Forms and it’ll switch to the other DB to fetch images.
Then on the slave installation, either:
- write a simple plugin to disable access to the Images panel (or redirect people to it); or
- edit
admin_config.php
and restrict rights to the Images panel; or - install a rights management plugin (e.g. bot_privs, smd_user_manager) and limit rights to the Images panel that way.
Thus you can only manage images from the master installation. All other templates swap to the master for image-related functionality on-the-fly. And if they’re on the same server it’s less expensive to hop between them as you don’t need to supply new credentials each time.
The only hiccup with that approach is that your admin-side image functionality (e.g. assigning image IDs to articles) is more tricky because you need to hop to another instance to find the IDs.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Two textpattern instances with one image folder
Didn´t know rah_swap.
Already installed it and… yeah that should work.
Going to play around with it and if I resolved the hiccup I come back. =)
Thanks a lot guys!
Offline
Re: Two textpattern instances with one image folder
That wasn’t quite what I meant with rah_swap. It would be useful to access the same image base from several admin areas, so you can insert image ids, or assign them to categories to automatically create galleries (though I can see a danger there through potential conflicts from the different sites). I was merely mentioning that swapping db connections seems to be a possibility, though I’m not sure whether txp’s in-built db functions can cater for that in the present form.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Two textpattern instances with one image folder
jakob wrote #302877:
It would be useful to access the same image base from several admin areas, so you can insert image ids, or assign them to categories to automatically create galleries.
Core can’t help with that. There are no callbacks at the DB abstraction layer. But there’s always smd_tabber :-) That would allow you to construct your own Images panel that uses rah_swap to read/write a “remote” DB from a slave installation. Lotta work, but doable.
EDIT: You’d be limited to storing images in the categories that are defined on the master site though, which is a major limitation. The txp_image table can only store one category so if you’re using a remote image tree, the DB mimics that and your slaves all effectively have the same info.
The only other approach might be to symlink the Images folder, then you have independent databases and one image folder. Would that work? You’d be at the mercy of what happens if two people update the same image thumbnail or delete an image, but at least you could assign different meta data/categories to the same image on a per-site basis.
Last edited by Bloke (2016-11-15 10:14:15)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Two textpattern instances with one image folder
What if we would just swap prefixes instead of whole database connection? Would that help?
I think for a small site with, let´s say 3 languages… it could all easily be stored in one DB.
That would “just” mean that txp_images and txp_category have to swap the prefix.
Offline
Re: Two textpattern instances with one image folder
Unfortunatly I cannot get rah_swap to work.
There is always an error:
Warning: Missing argument 2 for php(), called in …/textpattern/lib/txplib_misc.php(812) : eval()’d code on line 25 and defined beim Verarbeiten des Bausteins
Might that be due to incompatibility with my txp version (4.5.7)?
Offline
Re: Two textpattern instances with one image folder
Hi,
It’s a plugins bug, replace php('echo 1;')
with php(null, 'echo 1;')
on line 25.
Offline
Re: Two textpattern instances with one image folder
Thanks. Error is gone but still not working. Have to investigate more.
I would like to come back to Stefs suggestion of symlinking two folders.
Where is the difference of creating a symlink or just telling both textpattern instances (located in subfolders) to take “../images” as their common image folder?
Problem would be that in both cases newly uploaded images are only known by TXP instance itself and not by the other one, right?
Offline