Halland is a Wordpress theme built by Region Halland, based on Sage.
```shell themes/halland/ # โ Root โโโ app/ # โ Theme PHP โ โโโ Acf/ # โ ACF Fields โ โโโ controllers/ # โ Controller files โ โโโ Theme/ # โ Enqueue files, register sidebars โ โโโ Traits/ # โ Traits used in the theme โ โโโ admin.php # โ Theme customizer setup โ โโโ filters.php # โ Theme filters โ โโโ helpers.php # โ Helper functions โ โโโ setup.php # โ Theme setup โโโ composer.json # โ Autoloading for `app/` files โโโ composer.lock # โ Composer lock file (never edit) โโโ dist/ # โ Built theme assets (never edit) โโโ node_modules/ # โ Node.js packages (never edit) โโโ package.json # โ Node.js dependencies and scripts โโโ resources/ # โ Theme assets and templates โ โโโ assets/ # โ Front-end assets โ โ โโโ config.json # โ Settings for compiled assets โ โ โโโ build/ # โ Webpack and ESLint config โ โ โโโ fonts/ # โ Theme fonts โ โ โโโ images/ # โ Theme images โ โ โโโ scripts/ # โ Theme JS โ โ โโโ styles/ # โ Theme stylesheets โ โโโ functions.php # โ Composer autoloader, theme includes โ โโโ index.php # โ Never manually edit โ โโโ screenshot.png # โ Theme screenshot for WP admin โ โโโ style.css # โ Theme meta information โ โโโ views/ # โ Theme templates โ โโโ layouts/ # โ Base templates โ โโโ partials/ # โ Partial templates โโโ vendor/ # โ Composer packages (never edit) ```
Clone Halland into the themes directory of your Wordpress installation and install dependencies:
$ cd <your site>/web/app/themes/
$ git clone https://github.com/RegionHalland/halland.git
$ cd halland
$ composer install && yarn
Update resources/assets/config.json
settings:
devUrl
should reflect your local development hostname, for example http://site.test
publicPath
should reflect your WordPress directory structure (/web/app/themes/halland
or /wp-content/themes/halland
for non-Bedrock installs)Build commands
yarn start
โ Compile assets when file changes are made, start Browsersync sessionyarn build
โ Compile and optimize the files in your assets directoryyarn build:production
โ Compile assets for productionAlmost all of the CSS on the front-end is defined in our styleguide. Halland uses it by looking for the environment variable COMPONENT_LIBRARY_URI
. If the variable can't be found, Halland defaults to the styleguide published on Github Pages.
If you want to work with CSS, set up up a local version of the styleguide by following the instructions in it's repo and make your changes there.
Allow requests to your local version of the styleguide by adding the following headers to it's nginx config:
SSH into your Homestead server and edit the styleguides nginx config:
$ cd ~/Homestead
$ homestead ssh
$ sudo nano /etc/nginx/sites-enabled/styleguide.test
Place the headers in the server block of the nginx config:
# Allow CORS
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
Reload the nginx config.
$ sudo service nginx reload
Halland uses Advanced Custom Fields to create custom fields and ACF Export Manager to save the field definitions as .php
and .json
files, so that we can keep them under version control.
The field definitions are imported automatically with ACF Export Manager. The export manager will automatically import all field groups defined in /halland/Acf/Import.php
.
To be imported, they must first be exported by following the instructions below. โคต๏ธ
Create your field group in the Wordpress admin panel like you normally would under Fields โ Add new.
Over the Save / Publish button to the right, you will find your field groups unique ID. It looks something like group_5b716c7b279da
. Copy the field groups ID and add it to the array defined in /halland/Acf/Import.php
:
$acfExportManager->autoExport(array(
...
...
'my-new-fieldgroup' => 'group_5b716c7b279da'
));
Save / Publish your field group and ACF Export Manager will create a .php
and a .json
file for your new field group in each respective folder. Make sure to commit these files.
First of you need to identify the filename of the field group you want to edit. The easiest way to do this is probably to look at the key-value pairs found in the import array in /halland/Acf/Import.php
.
For minor changes you can edit the field groups directly in code. Remember to edit both the .json
and the .php
files found in /halland/Acf/<json or php>/my-new-field-group.<json or php>
.
For bigger changes you might want to use the admin panels interface. Go to Fields โ Tools and import your field groups .json
file (found in /halland/Acf/json/my-new-field-group.json
).
Edit your field group. When you Save / Publish, the changes will automatically be exported to code. Commit your changes! ๐ค
TBD