Canvas: Views, and Controller Overrides

Created on 7 Jan 2017  路  6Comments  路  Source: austintoddj/canvas

I've installed canvas, and wanted to customize certain views and add functionality to the posting. But after running the php artisan canvas:install command, and setting everything up. I didn't see the library clone over the built in views, controllers, etc. Was this supposed to happen? If not, then I have some questions.

  • Customize the built in views;
    Were we supposed to clone over the built in views from
    /vendor/cnvs/easel/resources/views/*?

  • Expand functionality;
    Same question as above but with the controllers from
    /vendor/cnvs/easel/src/Http/Controllers/*?

Most helpful comment

@PatrickJoannisse anyone can create a canvas theme. Its composer.json needs 2 special properties to be picked up automatically as a canvas theme:

  • type (must be _canvas-theme_)
  • extra.canvas-theme (exists to specify theme name and directories)

Example _composer.json_:

json { "name": "someone/mytheme", "description": "Theme for Canvas.", "keywords": ["canvas", "theme"], "type": "canvas-theme", "license": "MIT", "authors": [ { "name": "Someone", "email": "[email protected]" } ], "extra": { "canvas-theme": { "title": "MyTheme", "directories": { "public": "public", "views": "resources/views" } } } }

You may use the following repository as a starting point to create your theme: https://github.com/cnvs/canvas-theme-paper

Official theme documentation is coming soon...

All 6 comments

If I understand your question properly, when you install canvas using the command line, you are simply running an install wizard that will get some inputs (it'll ask you for an email, a password and some other details) and configure your blog. It creates the config/blog.php file, and adds the info to the database. To autoload will simply refer to the vendor files without needing to clone anything.

On how to customize the built-in views and create a theme, however, I'm still trying to figure it out. I noticed that for creating your own theme and having it picked up automatically, it needs to be located in the vendor/cnvs folder and be prefixed canvas-theme. I'm really not sure about this. I'd like to see this handled differently to be honest.

Good questions @dlopez @PatrickJoannisse. You're pretty spot-on with the description of what is going on in the backend during the installation.

As far as themes are concerned, right now they are kept in the cnvs organization repo, added to Packagist from there by me, and then you'd be able to require them and start using one. Definitely open to other ways of doing it if you guys want to suggest some.

@dlopez Canvas views and controllers are loaded from the core _package_ (Easel) [/vendor/cnvs/easel/], this is the correct behavior.

  • Custom controllers go in /app/Http/Controllers as per a regular Laravel install.
  • Customized canvas' views go in /resources/vendor/canvas.
    Note: Any customization to views may be overwritten when you change themes so I suggest building your customizations into a theme.

@PatrickJoannisse anyone can create a canvas theme. Its composer.json needs 2 special properties to be picked up automatically as a canvas theme:

  • type (must be _canvas-theme_)
  • extra.canvas-theme (exists to specify theme name and directories)

Example _composer.json_:

json { "name": "someone/mytheme", "description": "Theme for Canvas.", "keywords": ["canvas", "theme"], "type": "canvas-theme", "license": "MIT", "authors": [ { "name": "Someone", "email": "[email protected]" } ], "extra": { "canvas-theme": { "title": "MyTheme", "directories": { "public": "public", "views": "resources/views" } } } }

You may use the following repository as a starting point to create your theme: https://github.com/cnvs/canvas-theme-paper

Official theme documentation is coming soon...

@reliq Thanks for the quick breakdown of how to create a theme. Definitely, the documentation would help. We all hate writing it but I guess somebody has to ;)

You're welcome @PatrickJoannisse. It's coming soon 馃樃


See: https://cnvs.readme.io/v3.0/docs/theme-development

Was this page helpful?
0 / 5 - 0 ratings

Related issues

karlmonson picture karlmonson  路  10Comments

connecteev picture connecteev  路  6Comments

soipo picture soipo  路  4Comments

C0deBr8kr picture C0deBr8kr  路  6Comments

reliq picture reliq  路  4Comments