Welcome to vbmods.rocks! Get FREE and paid vBulletin mods, plugins, addons, API extensions, custom modules, custom BB Codes, vBCloud mods, CORE hacks, JS hacks, custom coding by Glenn, an ex-vBulletin Developer. You must register before you can post, download the files or copy the code from the free plugins.
The profile fields have absolute position in CSS in order to change its location. Due to this, it cannot automatically adjust the alignment based on the length of the text. I recommend changing the "Datestamp Display Option" to "Normal" in "AdminCP > Settings > Options > Date and Time Options" so that it will always show the actual date and not Today or Yesterday.
How hard would it be to toggle the left hand vs horizontal css calls based on a user profile field value?
I added a CustomField as a radio button (table userfield, column field18, possible values "Left" and "Horizontal") and have tried a few things to get this to work, but this goes a bit beyond what I've done with templating....
My thought was to add a statement like this below to css_additional.css and only render the override if it's set to "horizontal" in the profile.
If that works, I might do the same to add a "Large Print" option for my aged customers...
Code:
<vb:if condition="$userInfo['field18'] == 'Horizontal'">
---> all the horizontal css overrides <---
</vb:if>
That isn't working... Can I ask what the syntax would be to evaluate the table value directly?
I know the easy route would be to have a left and a horizontal style option.... but imagine a site allowed users to customize their palette to their favorite sports team.... that's more or less what we have, except that it's railroads.....
The $userInfo object is not available in css_additional.css. You would need to call the fetchUserinfo method from the user API to get the profile info of the viewing user. But I don't recommend doing the logic in css_additional.css template (or any CSS template for that matter) because adding dynamic data to it based on user info of the viewing user means you wouldn't be able to store CSS as files.
What I recommend is creating a template hook in header_head hook location and fetching user info and then dynamically adding "postbitLayout--horizontal" class to <html> tag via JS based on the user's profile field value. Then in css_additional.css template, prepend all CSS selectors with .postbitLayout--horizontal so that the horizontal postbit layout will only be applied if that class is present.
1) Created a new template css_add_horiz.css which has all the elements with the !important; tag set
2) Inside the Header template, invoke fetchUserInfo just after the header_head hook
3) Follow that with a <vb:if statement which tests for the profile value, and invokes {vb:cssExtra css_add_horizontal.css} when true.
Toggling within the user settings, this works flawlessly right now.
Comment