XF 2.0 Attaching a Style Property Add-On to a Specific Style?

Brad Padgett

Well-known member
How would I go about attaching a style property add-on or framework to 1 specific style.

Currently if I create the style property add-on it works for all styles and not 1 in particular.

For example UI.X 2 add-on only works on UI.X styles. How can I achieve the same for a style I create?

Thanks for the help.

I'm going to tag @Russ and @Jake B. just in case they can help.
 
Probably something like "if style name or parent style name == some keyword". Try changing UI.X style names, including the base style with the framework, creating new styles with a UI.X name etc.
Other possibility could be that you look for a style property which typically should only exist in your style because of branding. For example the style prop group for the framework or something similar. The style entity inherits a style prop entity and the style prop repo has several methods to check style props, like getEffectivePropertyInStyle etc.
 
@S Thomas I've already learned how to reference style properties in templates to get them to work.

I just simply want to know how I can add a style property add-on to 1 specific style at a time. Instead of having it attach to all styles when being installed.

If it attaches to all styles then that's not a good framework to use.
 
.. what is a "style property add-on"? Are you talking about template modifications, actual php code or what is that supposed to be?
 
.. what is a "style property add-on"? Are you talking about template modifications, actual php code or what is that supposed to be?

It's for making a style framework. Style property add-on meaning custom style properties for a specific style. To give it a framework.

Example being custom footers, welcome notice, custom node icon inputs. Different custom style properties that aren't default.
 
Create a base style (=framework), create child style(s), change child style props & templates, then export the child style(s)?
 
Create a base style (=framework), create child style(s), change child style props & templates, then export the child style(s)?

Yes that would work. However I want to make an add-on for it so I don't have to keep doing the same thing on every style. I can just attach the add-on to the style I was going to release. To make it simple. I would make the style properties in an add-on and attach it to a style. Rather than making an add-on that works for every style or doing it for each style and having to repeat it.

How would that exactly work if I was using a separate add-on? The only option available when doing it the "add-on" way is to make the style properties in the master style (which works for every style). There's no option to do that with a specific style.

If I don't do it in the form of an add-on then there's no base framework add-on and I have to repeat it for every style.
 
@S Thomas do you think that would work if I made a child of the master style for the add-on? Or is that even possible?

How can I do this with an add-on style property framework?
 
I just checked and the master style is the only one you can populate to an add-on. Any other styles cannot be populated to an add-on.

So that's the reason for my question in particular. It seems you can do it by each style but not when your using an add-on for it. You can only use the master style which is every single style at once. How can I go about attaching the add-on for only 1 style?

I'm going to take some people again just in case they get this. @Russ @Chris D @Jake B. Thanks if you can answer this question
 
No clue how you checked that but that's not how it's supposed to work. I already explained to you how you could create an addon which would be active only on particular styles (check for a property populated in your style only). Within the style repo there's also updatePropertyValues so you could target one specific style. Probably should read into that: https://xenforo.com/xf2-docs/dev/entities-finders-repositories/#the-entity-system

I don't think PHP is required for a framework/style property add-on to attach itself to one style. I highly doubt you need to use PHP. I think this is just a simple question no ones been able to answer. Anyways I suppose I could do what you mentioned with a base framework and then using children but this should be a simple question. This would not require PHP to my knowledge. I just don't know the answer.
 
Also I think you got me a bit confused @S Thomas this is not a PHP add-on I'm trying to create. Nothing in the database should be changed. I simply want to attach style properties to a specific style through an add-on that holds the style properties (instead of only adding them to the style directly).
 
If you have no plans to create add-on functionality, why don't you just create a style and put your properties in there? Then users would create a child style of your framework.
 
If you have no plans to create add-on functionality, why don't you just create a style and put your properties in there? Then users would create a child style of your framework.

I guess I could do that too. I just see that a lot of theme designers are using add-ons to do the same thing so I guess I just wanted to know how I could. It was more a less a question just wanting to know how to do it. However I guess you got a point on using a base framework and child themes.

Any reason you can think of why everyone is doing it with an add-on? What add-on functionality is most everyone using? Just wondering since most everyone is using an add-on. That's the main reason I was asking. In my opinion I had thought the purpose was to attach the same one to styles when they were ready to release it. But after giving it considering I could do the same thing with a parent framework and then export the style when I was ready.

Thanks for your advice. It's very helpful.
 
Add-ons give the ability to add extra functionality you can't inside of a style xml.

I see what you mean. I think an example of this would be sliders and stuff like that or when javascript is needed. I understand now. I appreciate your help.
 
Back
Top Bottom