AutoNav Custom Template Installation HELP Meh! plz ^_^
Permalink
I am working on my first theme and I wanted to know how to install custom templates for the auto-nav block with the theme as well so the end user won't have to use any ftp programs.
So that's all nothing changes in the controller.php?
Yes, no changes. The c5core will automatically search through every installed package whether they contain custom templates.
In the block auto nav i have /templates and /img will it create that folder and load the images into it as well or should I be referencing the /themes/themename/images ? I want to somehow keep it together so I can release this as an addon for people who want it even if they don't have the theme. Thanks for all the help btw I feel like a nub making my first theme.
I would use:
And in the code you can reach it like this:
/packages/YOUR_PACKAGE_HANDLE/images/
And in the code you can reach it like this:
$pkg = Package::getByHandle('YOUR_PACKAGE_HANDLE'); $imgdir = $pkg->getRelativePath() . '/' . DIRNAME_IMAGES;
Not completely sure if I follow I want two different things.
1. Have a custom template that can be installed independently of the theme for users who just want the menu so I would need the images to I guess be in the /packages folder for the autonav block.
2. For the theme installation install the custom template that is auto detected but also be able to make sure the images load from the directory inside /blocks this way it's not attached to the theme in any way if that makes sense.
1. Have a custom template that can be installed independently of the theme for users who just want the menu so I would need the images to I guess be in the /packages folder for the autonav block.
2. For the theme installation install the custom template that is auto detected but also be able to make sure the images load from the directory inside /blocks this way it's not attached to the theme in any way if that makes sense.
I'm not also sure that I'm following you right now.
I assumed you are familiar with the packages concept but if not, here's a good page to read:
http://www.concrete5.org/documentation/how-tos/designers/packaging-...
In your situation, I understood that you want to build a theme that includes a custom template and you want people to install those automatically, right? Probably also want to sell it in the marketplace?
If I'm correct, you should include all in a single package you build:
I assumed you are familiar with the packages concept but if not, here's a good page to read:
http://www.concrete5.org/documentation/how-tos/designers/packaging-...
In your situation, I understood that you want to build a theme that includes a custom template and you want people to install those automatically, right? Probably also want to sell it in the marketplace?
If I'm correct, you should include all in a single package you build:
/packages/your_package_handle/blocks/autonav/templates/your_template.php /packages/your_package_handle/images/ <-- All the images you want to include in the theme/custom templates within this theme /packages/your_package_handle/themes/your_theme/ <-- All your theme files
I personally handle this in a different way than Mainia is suggesting (and the way I do it should support your ability to move the template out of the theme in the future):
Instead of .../templates/your_template.php, put the template file here:
Then, inside that "your_template" directory put any supporting files (view.css, images directory, javascript, whatever). The only annoying part of this is that C5 doesn't provide a way (that I could tell) to consistently give you the directory that the template exists in. So I put this at the top of my template files:
Then all the img src's would be:
...So when you move it outside of this package you have to remember to change that $imgPath thing at the top of the file, but other than that everything is clean and stays in one directory.
Instead of .../templates/your_template.php, put the template file here:
/packages/YOUR_PACKAGE_HANDLE/blocks/autonav/templates/your_template/view.php
Then, inside that "your_template" directory put any supporting files (view.css, images directory, javascript, whatever). The only annoying part of this is that C5 doesn't provide a way (that I could tell) to consistently give you the directory that the template exists in. So I put this at the top of my template files:
$imgPath = DIR_REL . '/packages/YOUR_PACKAGE_HANDLE/blocks/autonav/templates/your_template/images';
Then all the img src's would be:
<img src="<?php echo $imgPath; ?>/something.jpg" />
...So when you move it outside of this package you have to remember to change that $imgPath thing at the top of the file, but other than that everything is clean and stays in one directory.
By the way, I recently filed a bug report about this issue... please "upvote" it by going here and clicking the green "plus sign" button:
http://www.concrete5.org/developers/bugs/5-5-2/blockviewtemplateget...
http://www.concrete5.org/developers/bugs/5-5-2/blockviewtemplateget...
thnx Jordan & Mainio between the both of you I think I got what was needed but I'll test it on a fresh install
Antti / Mainio