2 jamroom sites, 1 database

alt=
@andrusito
8 years ago
302 posts
Hi,

How can i use the same database in 2 different JR instalations except for the jr_jrcore_settings table? that should be different in both instalations.

Is that possible?

Thanks!!!
updated by @andrusito: 12/26/16 04:59:50PM
paul
@paul
8 years ago
4,326 posts
I don't think this is possible.
What are you wanting to achieve? Presumably you want to share audio and video etc. between two sites? Some sort of custom module to synchronise items might be a way to go if so.
hth
Paul


--
Paul Asher - JR Developer and System Import Specialist
michael
@michael
8 years ago
7,711 posts
Haven't done it so don't have the code for you, but for concepts I would test to see if these were possible:
* use the events and listeners system to pick up on any request to the 'settings' table and change its destination database. (i worry that might effect the other tables too though.)

* During the jrCore_init() function the /data/config/config.php file brings in all of the connection information. When settings stuff is coming in, change the variables for $_conf['jrCore_db_name'] $_conf['jrCore_db_user'] and $_conf['jrCore_db_pass']. Same issue as above though, how to do it for just the single table you're interested in.

* maybe store the settings table in a third separate database and make a script so that both sites are connecting to the same 3rd database which would mean the same codebase on both sites.

* maybe use a different prefix. inside the jrCore_db_table_name() function that goes and gets the correct database table name, have a different prefix for each site, but a single actual database. then you'd just need to adjust the $_conf['jrCore_db_prefix'] to determine which database to use. This probably has the most merit I would think.
alt=
@andrusito
8 years ago
302 posts
Thanks @michael

@paul, because i need to show my JR website inside an app. But inside the app, the download links don't work unless they have the prefix "external://"

So I have to turn this: http://devocionmusical.com/audio/download/audio_file/2585
into this: external://http://devocionmusical.com/audio/download/audio_file/2585

That's why I think a copy of my actual JR database can help me if I use it in a new JR installation. Then I also can install the 'Template Injection' module to achieve the 'external://' issue.
brian
@brian
8 years ago
10,145 posts
Why not just rewrite the URL in your app?

Jamroom is not setup to run 2 different sites off of one database - that's not going to work.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
@andrusito
8 years ago
302 posts
I know that is the very best solution, but as I said the download links of my website don't work inside the app unless they have the prefix "external://"

And I if add that prefix, then the download links don't work for mobile or desktop users.

So, i was looking for an alternative solution :(
updated by @andrusito: 09/01/16 07:38:04AM
brian
@brian
8 years ago
10,145 posts
andrusito:
I know that is the very best solution, but as I said the download links of my website don't work inside the app unless they have the prefix "external://"
So, i was looking for an alternative solution

It's not clear to me what you can't just do a string replace on the URL - i.e.

str_replace('http://', 'external://', $url);

The concept is the same regardless of the language you are using for your app.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
@andrusito
8 years ago
302 posts
Oh sorry, I did not understand what you meant in your first comment.

The problem is I can't edit the app code.

I'm trying to build the app with an online service. This service uses some kind of plugins to create the content. Among all plugins, there's one that let me show any URL inside the app frame. So, i want to use that plugin to show my JR website url: devocionmusical.com

Everything is ok. The desing looks good, the artist profiles, etc. except the download links. They are not working inside the app frame.

So this link http://devocionmusical.com/audio/download/audio_file/2585 doesn't work unless preceded by the prefix 'external://'

The solution you suggest would be valid if I could edit the app code, but the service don't allow changes in that level.

Maybe the panorama is more clear now.
brian
@brian
8 years ago
10,145 posts
Then you will have to do something custom or use the Template Injection module - this is not something that is supported by JR.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
@andrusito
8 years ago
302 posts
The Template Injection module works very good, and it solves the problem with the download links on the app. Yes.

But if I use it, all users who visit the website through their phone browsers or their computers can't download music, because the new download url with 'external' prefix is not recognized by those browsers.

So, i solve a problem but also generate another one on the other hand.

That's why I thought if I have 2 websites with the same content, BUT one with Template Injection module, it could work...
brian
@brian
8 years ago
10,145 posts
You don't want 2 sites - that's way, way overkill for what you need.

When a visitor hits your site in your app how do you know? Is there a specific header or agent string that is used so you can differentiate an app client from a regular browser?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
@andrusito
8 years ago
302 posts
mmm no, i don't have any specific header or string for that. I don't know how to differentiate them..
michael
@michael
8 years ago
7,711 posts
Thats what you need, a way to differentiate that the request is coming from the app, then brians idea is the best one.

so add a page and put a {debug} in that page then see if you can find anything in that debug to identify that the request is coming from the app.

Docs: {debug}
https://www.jamroom.net/the-jamroom-network/documentation/jamroom-developers-guide/1477/debug

Or if the app can add something extra to the urls it requests like ?__theapp=true then you can make a module to check for that and add the required replacements.
alt=
@andrusito
8 years ago
302 posts
Can't find anything in debug.

I don't know how to identify users who come from the app. I mean, is it possible to identify them?
brian
@brian
8 years ago
10,145 posts
If you cannot identify the users coming from your app then you're not going to be able do anything about this. You need to contact whoever makes your app (or the developer of the system that makes your app) and ask them about including custom headers in HTTP requests so you can identify your app users on your back end.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
@andrusito
8 years ago
302 posts
Hi Brian,

I've run this tool https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending

into my Android app and this is what I get about USER_AGENT:

Mozilla/5.0 (Linux; Android 5.1; XT1032
Build/LPBS23.13-56-2;wv)
AppleWebKit/537.36 (KHTML, like Gecko)
Version/4.0 Chrome/42.0.2311.138 Mobile
Safari/537.36

And this for the iPhone app:

Mozilla/5.0 (iPhone; CPU
iPhone OS 8_1_1 like Mac OS X)
AppleWebKit/ 600.1.4 (KHTML, like Gecko)
Mobile/12B435

How can I use that information? How can I show a different mp3 downloads URL for users who come from this browsers?

Thanks
michael
@michael
8 years ago
7,711 posts
That info should also show up in the $_SERVER variable array in your modules php files, so you can use that as a trigger to do some switching.

Just to be clear, we haven't built what you want build, so don't have any reference, these are just ideas that a programmer can work with to get the system set up. To have definite answers for you we'd need to build it then tell you how it was built. ( not going to do that :) )
screenshot_headers.png

alt=
@andrusito
8 years ago
302 posts
Ok, I thought there was a simple way to include that code in a conditional tag.. or something like that.
I don't know 'cause I'm not a programmer.

Thanks anyway @michael.
brian
@brian
8 years ago
10,145 posts
It's not going to be a USER AGENT string - it's going to likely be a custom header -i.e.
X-Built-With
Or something like that. You need to contact the developer of your mobile app - without being able to uniquely identify your app requests you're not going to be able to do what you want. This is not something Jamroom can do for you - your app must send it.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags