-
I have Chyrp Lite in a subdirectory and I have 5 other subdirectories on my site, some with a lot of pages. I have been playing around a bit and I think I can do this quite easily, but I am not sure about that, I do not want to have to change huge amounts of native Chyrp Code. Say that I have one main installation in the root and several others in subdirectories, I was thinking of making all the installations ONLY FOR THE user-, groups- and Permissions- tables point to the main database. That way users will be logged in for all of my sites and not only one. Can you please point me in the right direction where to look to make this happen? Or will it require huge modifications to the source-code? (I would like to try to build a module for this, that you can enable in every installation that lets you point to another database, only for the user-part). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hello there, I think trying to use multiple databases is going to be impossible because of Chyrp Lite's architecture, but there is another option that might work. Chyrp Lite has the concept of a "table prefix" - this is a unique identifier you can specify during installation, which will be added to all table names created by Chyrp Lite. For example, if you specify the table prefix "myblog_" then Chyrp Lite will create tables named "myblog_posts" instead of "posts", "myblog_pages" instead of "pages", "myblog_users" instead of "users" and so on. This feature allows you to run several blogs using a single database and unique table prefixes. Now, it might work to modify one method in one file of the core, to make it do something different with this prefixing feature depending on the table being requested. You might be able to make prefixing work as normal, unless the table is one of the ones you want to be shared across installations. To do this, modify this line in includes/class/SQL.php and replace it with:
Now you can run multiple blogs in subdirectories, all using the same database and having their own prefixed tables for most things but sharing their users, groups, permissions, and sessions tables. This will mean that a user logged into one blog is logged into them all, so long as they are served from the same web domain (example.com/blog1/, example.com/blog2/). I must stress that Chyrp Lite isn't designed to do anything like this, so you will be in uncharted territory. I haven't thought through all the implications of this change so it might just fail for a reason I haven't considered yet. But I will try to help as much as possible. Good luck! |
Beta Was this translation helpful? Give feedback.
-
Hi! I have been working on this and experimenting and think it can be done but because Chyrp is not designed to do this I think it wouldn't be the best option for the future. New releases could break it or cause trouble. Originally I wanted all my websites to be interactive but I couldn't find a good and secure way until I stumbled upon Chyrp Lite, now I am thinking of starting again from scratch and rebuilding everything. For this I would love to use the feature that you can make pages and subpages etc. but I really need an option to enable comments on pages. I have a feeling that this could be done pretty easily, am I right? |
Beta Was this translation helpful? Give feedback.
I think this would be a good use case for additional Twig functions defined by a module. Here's how it works: You create a basic module that has a few functions named like
twig_function_<<your Twig function name>>
, for exampletwig_function_render_family_tree()
.Then in any Twig template, you can call the function
{{ render_family_tree() }}
to do some work and output any HTML you desire, or a filter{{ start_position | render_family_tree }}
if you prefer. You can see exactly how this works by inspecting Leaf, Chyrp Lite's extension class. Functions and filters defined by a module would work just like the built-in functionsmailto()
andpaginate()
, or the filtersthumbnail
andtranslate
- …