This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

herizo.ludovic16552
herizo.ludovic16552

Hi all,

Working on a little plugin, i'm searching a way to change the view file to be loaded for requests but seems no way to find how to do it without changing core files. the idea is to have different versions of a same page depending on a parametter or url . .like mobile AMP version or translation /en , /fr etc..

May be someone know how to handle that. Thanks

Last updated

pratyushpundir6424
pratyushpundir6424

If the page needs to change based on url, you could just create different pages each targeting the required urls. For language based stuff (/en, /de, /fr, etc.), take a look at the Translate plugin. It has a good introduction here if needed.

I'm not sure what your plugin intends to do yet. Some elaboration on what the purpose here is might allow people to be more useful.

herizo.ludovic16552
herizo.ludovic16552

Hi,

i'm simply searching to extend / override core classes like it's possible on codeigniter or any other php framework even cms like prestashop to change behaviors as need . I'm trying to create my own translation plugin for personal use.. probably more plugins later but overriding classes is something essential for some fonctionalities and i was surprised to see there is not easy way on octobercms.

concretely , i need now to redefine the fileloader system to change paths / filenames without editing the core files and classes.

Last updated

herizo.ludovic16552
herizo.ludovic16552

found it thanks.

i just needed routes.php inside the plugin and probably custom controllers to what i want

pratyushpundir6424
pratyushpundir6424

If you just wish to make your own Translate plugin, you could extend it however you like. See here https://octobercms.com/docs/plugin/extending.

Or if you just want more control over how you react to urls and what not, you could use Laravel's MVC ways instead of October's MV** philosophy and use of plugin/components. The way to do this would be to use a routes file to handle all routing and then use simple controllers like Laravel does. Example here https://github.com/daftspunk/oc-laravelapi-plugin

pratyushpundir6424
pratyushpundir6424

herizo.ludovic16552 said:

found it thanks.

i just needed routes.php inside the plugin and probably custom controllers to what i want

lol I just replied with the same solution. Glad you could work it out.

Last updated

herizo.ludovic16552
herizo.ludovic16552

Great thanks @pratyushpundir6424 you confirmed the solution and it was very helpfull for me.

pratyushpundir6424
pratyushpundir6424

No worries, good luck!

1-8 of 8

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.