XF 2.2 Style archive import/export, Style asset locations and Asset uploads

1596357918911.webp
Everyday administrative housekeeping often requires direct interaction with your server's file system.

Installing or upgrading a style, switching out logo graphics and other images on your forum you will invariably require a dust-off for your rusty old FTP client and an exciting adventure into arcane directory structures in order to upload them manually, while desperately not trying to overwrite the server's kernel or otherwise accidentally lunch the normally smooth operation of your forum.

Booooooring!

We have already acknowledged that these archaic methods will no longer do. XenForo 2.1 removed many barriers in order to allow one-click upgrades and add-on installs/upgrades from archive to be performed directly from your admin control panel in a much more convenient way.

But, we felt there was still more to do and that's what we're talking about today 👇
 

Defining asset locations for styles

Okay, stick with us here, as this takes some explaining, but it's worth it for the pay-off...

With XenForo 2.2, we're introducing the concept of Asset locations for styles, which can be used to define locations, usually directories, in which assets for your style are stored.

Assets can be anything from a font, a JavaScript file, an image or even a directory containing multiple files.

This is an example of how you might set up one of your styles:

Here we have defined an asset key called logos and pointed that at the styles/my_style directory.

Now this is defined, you are free to use the logos asset location in various places including in templates with the asset('logos') template function and style properties using the %ASSET:logos% placeholder.

These style properties now directly reference the three logo files in the styles/my_style directory that we defined as an asset location. If we ever change that asset location, it will update these three style properties automatically to point at the correct location.

Style asset locations are extremely powerful for child styles, too. You may want to make a derivative of this style which may involve changing some properties, and changing some of the logos to reflect your changes.

By default, child styles inherit style asset locations from their parents:

Much like style properties, you can customize an existing asset location in a style or you can add entirely new locations. Just type into an empty field to add a new one, or click the pencil icon to edit an existing one:

Because the style properties are also inherited from the parent and they are making use of the logos asset, no changes need to be made to the style properties themselves. The logos will now be served from the newly defined asset path.
I made a new style with no parent style.

I added an asset key of graphics and a path of styles/sixlxvi.

Then I went to the logo style property and used it to upload a logo. It uploaded the logo to data/assets/logo/logo.png. I was confused so I tried to type %ASSET:graphics%/logo.png in the box, but that does nothing.

To use the new uploading system and have the files go to styles/sixlxvi, what do I need to do differently?

Edit: Not sure why I posted this here. My brain wanted to post it in the styles forum.
 
Uploading assets and defining asset locations are a mutually exclusive feature.

If you’re designing a style to redistribute then you will have to place the files in your desired asset location manually.

Uploading files is great for end users of your style. It enables them to do things like upload a logo directly without using FTP and without overwriting default graphics which may be overwritten the next time they update their style.
 
Asset Uploads may now be one of my favorite new features. We have a field in our style where we can specify an image that appears on the right side of the header, opposite our logo. It replaced a static image that we had in 1.x that was a pain to change. In 2.1, I had to upload the image externally, then edit the field manually to get the image to show. With this feature, it now generally takes me more time to find the image and do some manipulation to get what I want than to upload and change it. Which is how it should be. So whereas I used to change it maybe quarterly or by season, now I can happily do a special image for a particular day, e.g. I put one up for Remembrance Day today. Nice job (and thanks to @Russ who provided the header image capability in the first place when I requested it during my 2.1 upgrade).
 
On my installation of 2.2.2 - I don't have the option to export as a style archive :/ I'm sure I did before. Is this an option, or something missing? Thanks
 
Thank you very much for this outstanding and long-awaited feature!

I've got two small questions:
1) Is it possible to use the new assets placeholder/function also in less/css-files?
In Example for the usage in font-face definitions:
@font-face {
font-family: 'TestFamily';
src: url('./styles/MyTheme/fonts/TestFamilyFont.eot');
src: url('./styles/MyTheme/fonts/TestFamilyFont.ttf') format("truetype"),
url('./styles/MyTheme/fonts/TestFamilyFont.woff') format('woff'),
url('./styles/MyTheme/fonts/TestFamilyFont.eot?#iefix') format('embedded-opentype'),
url('./styles/MyTheme/fonts/TestFamilyFont.svg') format('svg');
font-style: normal;
font-weight: 400;
}
If not, it would be great ;)

2) Is it planned to build up an language-importer/exporter - which can be use via cli?
That would be very great for an automatic deployment out of an VCS (VersionControlSystem).
 
We can only provide support to licensed customers. If you are licensed, please add your forum username to the Forum users page in your Account area and then post in the correct forum.
 
I just update to 2.2.8 and I don't see the option to import archive in my styles section. Am I missing something or just to stupid to understand what this feature actually is? There's only the standard import xml option.
 
I just update to 2.2.8 and I don't see the option to import archive in my styles section. Am I missing something or just to stupid to understand what this feature actually is? There's only the standard import xml option.
Never mind. It was a conflict with the Install & Upgrade addon from @ThemeHouse. Deactivating it worked.
 
Is it possible to use asset() inside a template modification of the extra.less file? We're developing a plugin that allows to set a custom icon for each forum. We load those icons inside css variables, and we need a way to set the correct url to the file. Using this would help us to have different files for each style by only changing the assets location path. Thanks!
 
Is it possible to use asset() inside a template modification of the extra.less file? We're developing a plugin that allows to set a custom icon for each forum. We load those icons inside css variables, and we need a way to set the correct url to the file. Using this would help us to have different files for each style by only changing the assets location path. Thanks!
This question likely belongs here: https://xenforo.com/community/forums/xenforo-development-discussions.34/
 
I found that was really easy to do.
Much easier than having to either a) copy paste something that mightn't work or b) having to search for in your files.
It's all now search for in files.
It's much better.
 
Much easier than having to either a) copy paste something that mightn't work or b) having to search for in your files.
Care to detail how to actually "import" a specific template edit that is not related to the style you are using and have it work?
I've generally found that using the TMS system for template edits works rather well across multiple styles.
 
Top Bottom