medienbaecker / kirby-modules

Plugin for modular Kirby websites
MIT License
73 stars 7 forks source link

Method placement #13

Closed iskrisis closed 3 years ago

iskrisis commented 3 years ago

I think we should be careful where we put methods.

'pageMethods' applies methods to all page templates and thats pretty global. I think with some of the methods it doesn't make much sense to have them global and should be on the pageModel instead (especially since we have them).

So the question is from 'renderModules', 'isModule', 'moduleName', 'moduleId' which are useful on any page.

I would say 'isModule' always returns something useful. 'renderModules' could be just on modules model but it doesn't do anything bad so it might also make sense to have them global.

'moduleName' and 'moduleId' i think belong only to ModulePage model.

We have to think about about every method where it should belong in future aswell.

iskrisis commented 3 years ago

I can make the PR after your opinion.

medienbaecker commented 3 years ago

I agree. moduleName and moduleId can definitely be moved to the ModulePage model.

I'm not sure about renderModules because I would use it on the parent page (which has a modules child and multiple module grandchildren) whose template (and model) could be anything. We could use global a ->modules() page method and use the renderModules method on the modules container only.

iskrisis commented 3 years ago

You are totally right i haven't realized that there is modules page between.