Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2021-12-09 11:45:46

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Two textpattern instances with one image folder

Bloke wrote #332148:

That’s a bind. Not sure if there’s any equivalent to CREATE VIEW. There’s CREATE TEMPORARY TABLE which can be used in a similar sort of way to make a ‘copy’ of another database on-the-fly but that’s more invasive as it needs to be done every session. Wouldn’t advocate that.

I wonder if there’s any way you could host a dedicated ‘image only’ Textpattern and use rah_swap to fetch stuff from it in your templates. So you could set up a shortcode maybe as a wrapper for <txp:images> which first connected to the images database. I’m not convinced that would work very well and it would require some additional plugin support for the Images panel (and Write panel if you use com_article_image or an equivalent plugin to help with adding pics to articles).

Can’t think of anything else off the top of my head, sorry.

Thanks, Bloke.

I was hoping there was another way to access the txp_image table in the master installation

Incidentally, I have made a shortcode that pulls in the image from the image folder on the master site. But it would be nice if there were access to the txp_image table


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#50 2021-12-11 08:53:34

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Two textpattern instances with one image folder

Bloke wrote #332148:

That’s a bind. Not sure if there’s any equivalent to CREATE VIEW. There’s CREATE TEMPORARY TABLE which can be used in a similar sort of way to make a ‘copy’ of another database on-the-fly but that’s more invasive as it needs to be done every session. Wouldn’t advocate that.

I wonder if there’s any way you could host a dedicated ‘image only’ Textpattern and use rah_swap to fetch stuff from it in your templates. So you could set up a shortcode maybe as a wrapper for <txp:images> which first connected to the images database. I’m not convinced that would work very well and it would require some additional plugin support for the Images panel (and Write panel if you use com_article_image or an equivalent plugin to help with adding pics to articles).

Can’t think of anything else off the top of my head, sorry.

Just tried to install rah_swap on a Textpattern v4.8.7 installation, but I get this error:

Warning “mysqli_real_escape_string() expects parameter 2 to be string, array given”.


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#51 2021-12-11 11:16:29

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Two textpattern instances with one image folder

Kjeld wrote #332165:

Just tried to install rah_swap on a Textpattern v4.8.7 installation, but I get this error:

Warning “mysqli_real_escape_string() expects parameter 2 to be string, array given”.

Hmm, I don’t see that function used at all in the current version’s code in his rah_swap GitHub repo.

You might want to try that version. You can either install it using composer as he suggest or compile it to a txt-installer as described here.

I’ve done that for you here – although it says v0.1.0 in the file and the plugin’s manifest.json, it is the code of what gocom calls the “forthcoming 0.2.0 version”, though nothing further has happened since then.

# Name: rah_swap v0.1.0
# Swap database on fly
# Author: Jukka Svahn
# URL: https://github.com/gocom/rah_swap
# Recommended load order: 5
# .....................................................................
# This is a plugin for Textpattern - https://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the "Install plugin" box:
# .....................................................................

H4sIAAAAAAAAE+1abXPbNhL+rl+BajzVy8iUZcdpKkceOc5LfZO4Pr9cJuNkNCAJSbhQhAqC
ltU0//12FwBF0ZKTXu/TTf0hIfGy2F08eHYXFO/3nvS/ZP0n/XrKZ6J+lPWf9euaT0fZgs/x
9ad+/U7oTKoU3w779b2gF+zh89N+nedmqjS+9Hr9+j/yz585u7rjUxrb2/MDRrmW2HJw0K9P
jZln/W53Is00D4NIzboThf+WF0VpscgiLefGrbwP0q6gm8Xc8JBngqmUjZMl9oH2U5HQTBjl
jMCWkeYLUrv3DFt6AfOr1Gr1Cx595hOZmXrfKzX3TYHSE/cmMlStUI/9wepnWZaLbDVtqy04
+KVKuRGrwdA3VjqfBaH8vRtTZ3elFZkYqTQVkRExq1+LezPnxgidstN3VysxZtWBC7N3y6t/
vl05J5HpZ/SQmQr0EsszmU4YZ0bM5gksyQyfBOwaeudJPpEpm/KMBs+VEamRPGFGMZ4kasHm
eZLg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finely-crafted code, design and txp

Offline

#52 2021-12-11 13:19:28

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Two textpattern instances with one image folder

jakob wrote #332166:

Hmm, I don’t see that function used at all in the current version’s code in his rah_swap GitHub repo.

You might want to try that version. You can either install it using composer as he suggest or compile it to a txt-installer as described here.

I’ve done that for you here – although it says v0.1.0 in the file and the plugin’s manifest.json, it is the code of what gocom calls the “forthcoming 0.2.0 version”, though nothing further has happened since then.

# Name: rah_swap v0.1.0...

Does this version work any better?

No error messages now! Thanks, Julian!

I downloaded the plugin from the Plugins section on this site…


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#53 2021-12-11 13:54:37

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Two textpattern instances with one image folder

I have been going through the help file of rah_swap.

Now, my English and Japanese installations share one database. The Japanese one uses the prefix ja_.

If I move the Japanese installation to a separate database, I should be able to pull the image information from the English installation, right? No need to create an ‘image only’ Textpattern?

Or, am I understanding this wrong?

Also, out of intellectual curiosity, if it is possible to have a plugin like rah_swap access a different database for a small piece of code, couldn’t the same be done for a table with a different prefix (or without one) in the same database?

EDITED

Just found this shortcode. Does it do what I asked about in the last question?

Last edited by Kjeld (2021-12-11 14:01:53)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#54 2021-12-11 17:54:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: Two textpattern instances with one image folder

Yes, pulling images from one of the installations is perfect for what you need. I wasn’t clear when I said “images only”: I meant one has real images in it and the other doesn’t.

As for the short code: yep. Does the same as rah_swap, essentially. All you’re doing is supplying (overriding) the default credentials supplied from config.php with different credentials that point to another database.

Since the image dir and prefs of the 2nd DB hold the path to the images files, as far as your host installation is concerned, they’re “local” to it.

The only thing you might have to watch is if the prefs have already been loaded, you may find they’re set to the host DB. So you might have to do a force refresh on get_prefs() somehow, after supplying the new credentials, and just after reassigning the old DB creds back. YMMV.

Last edited by Bloke (2021-12-11 17:58:36)


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

#55 2021-12-12 07:48:16

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Two textpattern instances with one image folder

Kjeld wrote #332168:

Now, my English and Japanese installations share one database.

I was just wondering how you are dealing with the alt attribute on this. Do you just use English or do you use another field for the Japanese site?

I am also wondering how search engines would interpret the hotlinking of images and the possible different alts.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#56 2021-12-12 08:28:36

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Two textpattern instances with one image folder

colak wrote #332172:

I was just wondering how you are dealing with the alt attribute on this. Do you just use English or do you use another field for the Japanese site?

I am also wondering how search engines would interpret the hotlinking of images and the possible different alts.

I haven’t quite solved this issue yet…

The shortcode I mentioned won’t connect me to the database. And I still have to try rah_swap with the Japanese installation on a separate database.

I also haven’t yet figured out how to change the Image directory in the Textpattern Admin Preferences to a folder on another domain. And I don’t know if that is actually needed if rah_swap works…

Julian advised me to install jcr_image_custom. It adds tables to txp_image in the DB, so you can access the foreign language data when you access txp_image


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#57 2021-12-12 08:44:48

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Two textpattern instances with one image folder

Incidentally, I did manage to make a shortcode a little while ago that pulls the image from another domain, and adds alt and caption in the body of the article.

But I would like to have everything go through the database if it is possible.

Here is the shortcode (named media_image):

<txp:images wraptag="figure" class='my-4 <txp:if_yield name="class"><txp:yield name="class" /></txp:if_yield>'>
<img src="https://www.OTHER_DOMAIN.com/images/ls-1024/<txp:yield name="id" />.jpg"
srcset="https://www.OTHER_DOMAIN.com/images/ls-640/<txp:yield name="id" />.jpg 640w,
https://www.OTHER_DOMAIN/images/ls-768/<txp:yield name="id" />.jpg 768w,
https://www.OTHER_DOMAIN.com/images/ls-1024/<txp:yield name="id" />.jpg 1024w"
class="d-block w-100" alt="<txp:yield name="alt" />"
/>
<figcaption class="figure-caption mx-3 mx-md-0"><txp:yield name="caption" /></figcaption>
</txp:images>

Responsive images in body of articles. Caption is only displayed if entered in photo. Class mx-3 mx-md-0 for figcaption adds margin on small screens. The caption left aligns with the images on medium screens and above.

Use this shortform:

<txp::media_image id="" class="" alt="" caption=""/>

ls-640, ls-768 and ls-1024 are different image sizes created with smd_thumbnail. This serves a smaller or larger image depending on the screen size.

class="" is to add an additional class. You can input multiple classes.

The other classes in this sample (like: figure-caption mx-3 mx-md-0) are actually bootstrap classes. Not really needed for the example, but I thought it would illustrate how to have classes in your shortcode.

Note that this only works for jpg files.

Last edited by Kjeld (2021-12-12 08:46:35)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#58 2021-12-12 10:20:40

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Two textpattern instances with one image folder

I just tested the following setup and it mostly works.

  • English installation on DOMAIN_1, with DATABASE_1
  • Japanese installation on DOMAIN_2, with DATABASE_2
  • jcr_image_custom to input both English and Japanese Alternate text and Caption in the English installation. The data is stored in txp_image on DATABASE_1
  • rah_swap around txp:images tag in the Japanese installation, pulls the Japanese Alternate text and Caption from txp_image in DATABASE_1

The only thing that I have yet been unable to figure out is how to pull the images from the image folder on DOMAIN_1. Currently, the images are served from the image folder on DOMAIN_2.

The path to the Image directory of the Japanese installation should be changed to DOMAIN_1. How do I do that?

I have tried adding a path to the name of the images folder in the Image directory of the txp Admin Preferences in the Japanese installation, but this doesn’t work. I think you can only adjust the name of the folder here, not the path?

Any advice, suggestions?

Bloke, you wrote this:

The only thing you might have to watch is if the prefs have already been loaded, you may find they’re set to the host DB. So you might have to do a force refresh on get_prefs() somehow, after supplying the new credentials, and just after reassigning the old DB creds back. YMMV.

I fear that is far beyond my expertise. I have no idea how to do this and where.


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#59 2021-12-12 10:51:12

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: Two textpattern instances with one image folder

I expect the reason it’s using the old image path (ihu) is because the prefs aren’t being refreshed as I suggested above. Give me a little while to get near a laptop and I’ll see if I can test it out and see the best approach.


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

#60 2021-12-12 11:00:00

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: Two textpattern instances with one image folder

Bloke wrote #332179:

I expect the reason it’s using the old image path (ihu) is because the prefs aren’t being refreshed as I suggested above. Give me a little while to get near a laptop and I’ll see if I can test it out and see the best approach.

Oh, thank you, Bloke!


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

Board footer

Powered by FluxBB