TechToThePeople / civisualize

CiviCRM vizualisation framework
https://lab.civicrm.org/extensions/civisualize/
GNU Affero General Public License v3.0
32 stars 34 forks source link

Allow templates and queries to be placed in a custom directory outside of the extension #117

Closed herbdool closed 1 year ago

herbdool commented 3 years ago

As far as I can tell, all the custom templates need to be inside the extension. Since we manage our extensions in a repo, this makes it a bit messy to handle.

tttp commented 3 years ago

I'm not sure what is the issue, but if you put the same folders in your extension (templates / dataviz and queries) it will work fine

On Wed, 29 Sep 2021, 22:05 Herb, @.***> wrote:

As far as I can tell, all the custom templates need to be inside the extension. Since we manage our extensions in a repo, this makes it a bit messy to handle.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TechToThePeople/civisualize/issues/117, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA7LKVWHMGIIU3WOEBYW2DUENWRNANCNFSM5FAWNNJA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

herbdool commented 3 years ago

@tttp I'm not sure what you mean, but let me be more explicit.

By extension, I mean this extension. We don't have a separate extension. I would like to be able to set an arbitrary path for this extension to find the templates and queries, much like Civi can set a customTemplateDir and customPHPPathDir. So we could set something like:

$civicrm_setting['Directory Preferences']['customTemplateDir'] = '/app/sites/all/civicrm_custom/civisualize';

And then under that could organize the files into ../civisualize/templates, ../civisualize/queries.

From the code I see that I can put them into the path set for customTemplateDir but it's not ideal.

tttp commented 3 years ago

The normal way of doing that is to create your own placeholder extension that just contains the needed templates and queries

Civisualize automatically look at them

Doesn't it solve your case?

On Wed, 29 Sep 2021, 22:05 Herb, @.***> wrote:

As far as I can tell, all the custom templates need to be inside the extension. Since we manage our extensions in a repo, this makes it a bit messy to handle.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TechToThePeople/civisualize/issues/117, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA7LKVWHMGIIU3WOEBYW2DUENWRNANCNFSM5FAWNNJA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

herbdool commented 3 years ago

Thanks for responding. I'm not sure it solves it as I've never created a placeholder extension. I guess I was thinking it would be good to have something more user-friendly.

tttp commented 3 years ago

https://docs.civicrm.org/dev/en/latest/extensions/civix/

this is not much more complicated than changing the template, less error prone and makes it easier to distribute and share your magic

Talking about that: if the viz you are planning to add are generic, your contribution will be greatly appreciated

On Thu, Sep 30, 2021 at 6:55 PM Herb @.***> wrote:

Thanks for responding. I'm not sure it solves it as I've never created a placeholder extension. I guess I was thinking it would be good to have something more user-friendly.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TechToThePeople/civisualize/issues/117#issuecomment-931497474, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA7LKXFONWOH7YNSJG6JYLUESJALANCNFSM5FAWNNJA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

artfulrobot commented 3 years ago

From the code I see that I can put them into the path set for customTemplateDir but it's not ideal.

Why is that not ideal? It saves you writing an extension and keeps all your stuff together.

tttp commented 3 years ago

"writing an extension" seems a bit overselling the "civix generate:module yourmodule" ;)

my experience is that to keep stuff together organised AND avoiding very painful upgrades, putting things in "shallow" extensions is the way to go, and it comes with a lot of batteries included (eg you can easily disable/enable or move around between civi)

Every time I had to deal with a civi install using custom templates, it was stuck on an old version because some random incompatibilities. I'm not saying it would happen with civisualise, but given that it's an extra 1 min work to create a new clean extension, I'd rather not suggest folks to go the custom template way

And for the broader community, my hope is that it makes it easier to have a look at what others do and take some bits (or everything), one can hope ;)

Does it make sense?

artfulrobot commented 3 years ago

@tttp yep, I use a custom extension for my stuff, too, but for the sake of validating the opinion... it's civix generate:module yourmodule then edit the info file (to avoid "what the hell is that FIXME" or blank names in the admin UI), then enable it. Then maintain it - e.g. if you created your extension and then the civix file goes out of date - as so many of them currently are - because of a change in PHP.

The result is the same: you have the same template files and your query files, it's just which dir they live in. When we break civisualize (e.g. to keep up with the external libs) then those template files, wherever they live, will need fixing.

I agree that custom template/php files per-se is a bad idea: it's a brittle way to add functionality or - worse- override existing core files, an extension is far better for that purpose; but when you just need to drop some civisualise files which do not overide any other files, I can't see why you'd need something with batteries when the wind-up method works just the same.

tttp commented 3 years ago

yeah, got a bunch of "FIXME" extensions indeed ;)

the need seems to be able to have multiple separate folders containing queries and templates and make it easy to move them around between civi instances.

I'm sure it could be coded separately, and I don't have a strong opinion about this feature, but out of laziness and predictability, I prefer the "extension as a custom folder" pattern, because it doesn't require any new maintenance/bug fix/potential security issues and voila ;)

artfulrobot commented 3 years ago

Well yes, if that's their need then I agree with you, I think I had misunderstood, which is why I was asking above why the custom templates solution was no good for them.