Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2016-11-15 16:08:05

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: Two textpattern instances with one image folder

Hi

You have nothing to change on textpattern, when you install textpattern you have a txp_image table DB created, if you have a second textpattern install with the same DB using a prefixe “prefix_” you will have a prefixe_txp_image created, go to phpmyadmin, delete that table and create a clone of txp_image and call it prefixe_txp_image and that s all.

Cheers.

Offline

#17 2016-11-15 16:08:28

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

Re: Two textpattern instances with one image folder

I don’t understand how either of those work, but I could be slow on the uptake ;-)

With dragondz’s suggestion, you can access and replace an image from both textpattern instances. That would work as long as nothing much changes, but how do you keep the two cloned txp_image tables in sync when actual details, e.g caption etc. are modified or new images are added? You’d have to re-clone, or have i missed something?

With smd_query, aren’t you essentially just getting at <txp:custom_field name="article_image" />. You can plug that into the id attribute of txp:images or txp:image_url to get the full image name/path. And, if you want to replace part of the path, you could wrap that with rah_replace or smd_wrap…

PS: @demoncleaner “because unfortunately I can’t get rah_swap working” … see your other post


TXP Builders – finely-crafted code, design and txp

Offline

#18 2016-11-15 16:19:38

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 228
Website

Re: Two textpattern instances with one image folder

I also do not quite get what Dragonz tries to explain. If I do so I will just have a clone of all so far posted images but no track n sync for further uploads.

What I did with smd_query to get the image of the other instance is now this:

<txp:smd_query query='SELECT t.image, i.ext FROM textpattern t JOIN txp_image i ON t.image = i.id WHERE (t.id = <txp:article_id/>)'><img src="../images_txp/{image}{ext}" alt="" /></txp:smd_query>

Which works fine. Where as your jakob would have been easier =).
But like this you would still go with the Article Image input.

Offline

#19 2016-11-15 16:31:48

etc
Developer
Registered: 2010-11-11
Posts: 5,674
Website GitHub

Re: Two textpattern instances with one image folder

I have forgotten that etc_query can query any db (under current credentials):

<txp:etc_query url="master_base"
    data='SELECT * FROM txp_image WHERE id IN(<txp:custom_field name="article_image" />)'
>
    <img src="../images_txp/{name?}" alt="{alt?}" title="{caption?}" />
</txp:etc_query>

should retrieve image info from your “master” txp db.

Offline

#20 2016-11-15 16:53:03

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 228
Website

Re: Two textpattern instances with one image folder

Even better. Thanks. But it would have to be {id?} instead of {name?}, right?

This solution works for me now. But would be cooler to still be able to work with images on the backend as usual.

Do you see any way to tell the textpattern backend it should forget about its prefix when it deals with txp_image table? So that the image handling on the backend side could also be concentrated on one and the same table? Assuming that all installs of TXP use the same DB of course.

There should be a point in the core where the prefix is set in front of txp_image. If I could avoid that and my en_textpattern is using my txp_image instead of en_txp_image that would be perfect. I won´t use image categories.

Offline

#21 2016-11-15 17:12:42

etc
Developer
Registered: 2010-11-11
Posts: 5,674
Website GitHub

Re: Two textpattern instances with one image folder

demoncleaner wrote #302911:

But it would have to be {id?} instead of {name?}, right?

Not sure, look in txp_image table.

There should be a point in the core where the prefix is set in front of txp_image. If I could avoid that and my en_textpattern is using my txp_image instead of en_txp_image that would be perfect. I won´t use image categories.

Sure, you could use image callback and change global DB->table_prefix (in 4.6), but image categories and authors would be looked for in wrong tables.

Offline

#22 2016-11-15 18:25:59

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 228
Website

Re: Two textpattern instances with one image folder

I am not sure what the image callback is. Could you give me a hint?
Authors and Categories I would not need.

What would be important is, that I could also give a list of image IDs like 2,4,8 in custom_field and use it with the ect_query trick to generate a slider for example.

With one image I got it running already. What if I want to have several images on an article, use a custom_field + ect_query to get the job done?

Offline

#23 2016-11-15 18:36:52

etc
Developer
Registered: 2010-11-11
Posts: 5,674
Website GitHub

Re: Two textpattern instances with one image folder

demoncleaner wrote #302917:

I am not sure what the image callback is. Could you give me a hint?
Authors and Categories I would not need.

Sorry, have no time to test right now, will do later

What would be important is, that I could also give a list of image IDs like 2,4,8 in custom_field and use it with the ect_query trick to generate a slider for example.

With one image I got it running already. What if I want to have several images on an article, use a custom_field + ect_query to get the job done?

The id IN(...) query above should be fine if you store image ids in Article image field.

Offline

#24 2016-11-15 18:39:03

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 228
Website

Re: Two textpattern instances with one image folder

Ah ok sure. Sorry. Should have tested myself before according to the IN…

For the callback I will try to see if I get any further and keep posting here in case.

Offline

#25 2016-11-15 23:01:57

etc
Developer
Registered: 2010-11-11
Posts: 5,674
Website GitHub

Re: Two textpattern instances with one image folder

This plugin should use non-prefixed txp_image table on the admin side:

# Name: abc_prefix v0.1 
# Type: Admin/AJAX plugin
# 
# Author: 
# URL: 
# Recommended load order: 5

# .....................................................................
# This is a plugin for Textpattern CMS - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................

YToxMTp7czo0OiJuYW1lIjtzOjEwOiJhYmNfcHJlZml4IjtzOjY6ImF1dGhvciI7czowOiIi
O3M6MTA6ImF1dGhvcl91cmkiO3M6MDoiIjtzOjc6InZlcnNpb24iO3M6MzoiMC4xIjtzOjEx
OiJkZXNjcmlwdGlvbiI7czowOiIiO3M6NDoiY29kZSI7czoyNzY6InJlZ2lzdGVyX2NhbGxi
YWNrKCdhYmNfcHJlZml4JywgJ2ltYWdlJywgJycsIDEpOw0KDQpmdW5jdGlvbiBhYmNfcHJl
Zml4KCRldmVudCwgJHN0ZXApIHsNCiAgICBnbG9iYWwgJERCOw0KICAgIC8vIFJlcGxhY2Ug
YXMgYXBwcm9wcmlhdGUuDQogICAgJERCLT50YWJsZV9wcmVmaXggPSAnJzsNCiAgICAvLyBF
bnN1cmUgdGhhdCBjb3JyZXNwb25kaW5nbHkgcHJlZml4ZWQgdGFibGVzIHR4cF9pbWFnZSwg
dHhwX2NhdGVnb3J5LCB0eHBfdXNlcnMgZXQgdHhwX3ByZWZzIGV4aXN0Lg0KfSI7czo0OiJ0
eXBlIjtzOjE6IjQiO3M6NToib3JkZXIiO3M6MToiNSI7czo1OiJmbGFncyI7czoxOiIwIjtz
OjQ6ImhlbHAiO2I6MDtzOjM6Im1kNSI7czozMjoiM2IxMWY5N2YxMzE2NDY0MmYxZjRhYzJl
NTE0YjZjMzIiO30=

Offline

#26 2016-11-16 07:38:45

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 228
Website

Re: Two textpattern instances with one image folder

Hell Yeah! Thanks a lot. You made my day.

Tried it first in 4.5.7 but there it did not work. 4.6.2 works fine.
So I will have to trie to update a couple of plugins now. Would have to do that anyway.
4.6.2 and etc rock! ;-)

Offline

#27 2016-11-16 08:14:09

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 228
Website

Re: Two textpattern instances with one image folder

Just a little info:
I got rid of bot_image_upload because it was not working on 4.6.2 and I installed your abc_article_image which I like a lot. Unfortunately it does not work together with abc_prefix.

I dont want to expand your time on that too much. But if there would be an easy solution for that I would be more than glad to hear it.

Last edited by demoncleaner (2016-11-16 08:14:39)

Offline

#28 2016-11-16 08:18:12

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: Two textpattern instances with one image folder

Hi

I should explain more my idea i think.

The two install share the same DB and intsall 2 has a prefix, then delete prefix_txp_image table (or rename it) and create a view of txp_image like this :

CREATE VIEW prefix_txp_image AS SELECT * FROM txp_image

After that change in the txp admin pref the directory to the image of the install 2 to point to the image directory of the intsall 1, then you will see images on both image tab install, i am not sur you can handle images (upload and delete) in the two install but you can test it, in local wamp server that works (relative path to the image folder on windows but not sure if that work on linux server).

Hope i am more clearer.

Cheers.

Offline

#29 2016-11-16 09:02:24

etc
Developer
Registered: 2010-11-11
Posts: 5,674
Website GitHub

Re: Two textpattern instances with one image folder

An alias is a brilliant idea, if it works, even more if it’s writable. I have never tried it, will do, thanks @Dragondz!

Offline

#30 2016-11-16 09:47:49

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 228
Website

Re: Two textpattern instances with one image folder

I tried it. All seems to work fine. This seems to be the best solution.
I can confirm that on Linux image folder set to “../images” is working.

Have to play around with it more. Two thumbs up Dragondz!

Offline

Board footer

Powered by FluxBB