It was possible to change the label text of every field per build mode/view mode in ds-6.x-1.x. Currently only the the label position can be adjusted - is this by design or is this an oversight (i.e. would you like a patch for this)?
Best, Fredrik

Comments

swentel’s picture

That's not an oversight. I just haven't figured out how I should handle the UI and if Field API stores the label per view mode. If you have patch, feel free to submit, it's on my list, but not as a high priority right now.

swentel’s picture

Title: Changing field labels per view mode ('label_value', not just 'label'-position) » Change field labels, field classes & wrappers per view mode

Changing title for more features

mortendk’s picture

evil themer subscribing

swentel’s picture

Status: Active » Needs work
FileSize
20.04 KB

First patch : important: the UI is horrible at this moment, that needs work.
At this point this should work though:
- other label per field
- remove all classes on outer div
- add extra classes on outer div
- change wrapper on the item div

The magic happens with overriding theme_field. The function is now theme_ds_field() in ds_extra module.
This patch is as an extra, so you need to enable the ds extras module and enable it on the 'extras' screen.

Patch works on latest dev. Needs work though of course, especially on the UI, but any other suggestions for making this even more cooler are appreciated of course!

swentel’s picture

FileSize
21.06 KB

Better patch with all tests passing. Will work on the UI somewhere this weekend or next week or if anyone else has the courage of course :) Again, more options, let me know!

mortendk’s picture

im gonna dig in tomorrow night and play around with it :)

mortendk’s picture

so been looking a bit into it seems to do some of the stuff, but lacks the last bits to make it bring it up to epic level ;)

right now we can remove the classes from the div wrappers - but no option for killing of the divs completely (no cure for divititis?)

The hopes was a field that can end up with the wrappers we want (or *gassssp* no wrappers at all!)
so sometingh like this pseudocoe:

no wrappers :
$field

wrapper:
<wrapper> 
  $field
</wrapper>

wrapper + class
<wrapper class="$class">  
  $field
</wrapper>

wrapper + label 
<outerwrapper>
<label> foo</label>
<wrapper class="$class">  
  $field
</wrapper>
</outerwrapper>

swentel’s picture

That's what I thought you'd say and I had in mind :) Will look into that further, colleagues are looking on the UI right now.

swentel’s picture

FileSize
22.98 KB

Updated patch with some UI and JS (note needs latest dev again, since I pushed the css/ds.admin.css) already - no functional changes yet.

kclarkson’s picture

will this patch allow me to style each field like in 6.x?

swentel’s picture

No, this is D7 only

swentel’s picture

FileSize
28.83 KB

Updated patch:
- can remove all wrappers
- can remove the 'field-items' wrapper
- can remove the field wrapper

It still needs extra classes on the field wrapper.

Another thing is that it's maybe too technical right now and we need to try another workflow. we'll see once we got the (extra) classes on the field wrapper in.

swentel’s picture

Status: Needs work » Needs review
FileSize
30.45 KB
19.69 KB

Even better patch, with a nice screenshot attached too :) The field classes box is now available too.

mortendk’s picture

wow that is smooth and sweet & just what the good doctor ordered for the cure for divitis !!!

but it looks like the label for inline vs above selected dont change from a span to a div?
Besides of that little thing, this is absolutely amazing :)

swentel’s picture

Status: Needs review » Needs work

Aha, didn't know that should happen for labels, makes sense indeed.

I'm also going to add a 'global' setting too at the top of the table that will affect all fields by default so you don't need to click like hell if you have a lot of fields.

mortendk’s picture

yup a global setting would make a lot of sense, though im enjoing every click where i kill off a ton of divs *div div div die die die*

jyve’s picture

FileSize
19.18 KB
16.82 KB

After a decent brainstorm, this is my proposal to make this awesomeness even more awesome:

1. Rename 'Field settings' to 'Output settings' so that it does not class with the current 'Field settings'.

2. Change the 'Output settings' form to the screenshot attached for more versatility.
By default all checkboxes are on, and the default 'element' and 'class attribute' fields should be filled in with the Drupal defaults.
If the class field is emptied, then no class tag is printed, but the tag itself is still printed.
The label row depends on the other selectbox where you choose to show the label or not.
Unchecked rows should have greyed out input fields.

3. I would then propose to drop the styles for fields as they are now, otherwise you have to go back and forth all the time.

4. Under the Display Suite menu, there should be a 'General output settings' section where you also get the 'Output settings' form, and a checkbox to make those settings the default settings for all fields. This then goes across all view modes and content types. However, you can still overwrite this default since a radiobutton will appear above the 'Output settings' form in the field UI, where you can choose 'general', or 'custom'. See second attached image.

Hope this makes sence. Mortendk feel free to add your feedback!

kclarkson’s picture

So will these changes allow me to style each field individually utilizing CSS?

Based on what I can tell from the posts it looks like you can not only style with CSS but also remove div tags.

Just wanted to be sure I am using this feature correctly.

swentel’s picture

These changes will allow you to change the output of the field, more or less like the comment in #7. Either starting from a default with the possibility to override them per field individually, but adding or removing wrappers and styles/classes on the fields.

jyve’s picture

To be more specific about your question, it will not allow you to change the CSS, it will allow you to optimize the default HTML output so that you have cleaner HTML and can write cleaner CSS.

mortendk’s picture

jyve sounds like clever suggestion you have :)
im all for it :P

swentel’s picture

FileSize
10.83 KB
29.01 KB

Here's the start of the patch that tries to incorporate the stuff mentioned in #17 and a screenshot too :)

With this patch, by default, you get nothing, nada markup around fields (except for the label which gets a div).

todo: default setup.

I'm also thinking about something extreme for ultimate power where you'd be able to define special theming functions (if you really need to go extreme) and select a theming function for that particular field. So in the end, this patch might do this:

- remove everything by default (working)
- setup a default (needs to done yet)
- change markup per field (working)
- define external functions which you can select (starting with one, which would be the original theme_field() function)

Any advice on that theming function or am I going to wild here ?

mortendk’s picture

defining extreme functions would überrock so hard i dont have words for it!
a simple thing could be a links thats rewritten with classes n crap markup for some fance jQuery thingie (if you wanna go that ways

frega’s picture

would love to test & help with one :) but i can't the patch to apply; whilst i am not totally new to the fancy git thing, i might just get something totally wrong ... after checking out 7.x-1.x branch; running git apply -v 1053912_4.patch gives me:
Checking patch css/ds.admin.css...
Checking patch ds.api.php...
Checking patch ds.field_ui.inc...
Checking patch ds.module...
Checking patch ds.registry.inc...
Checking patch js/ds.js...
Checking patch modules/ds_extras/ds_extras.module...
error: while searching for:
// Clear module_implements cache and rebuild menu.
cache_clear_all('entity_info:', 'cache', TRUE);
cache_clear_all('module_implements', 'cache_bootstrap');
menu_rebuild();
}

/**
* Implements hook_permission().
*/
function ds_extras_permission() {

error: patch failed: modules/ds_extras/ds_extras.module:131
error: modules/ds_extras/ds_extras.module: patch does not apply
Checking patch tests/ds.base.test...
Checking patch tests/ds.entities.test...
Checking patch tests/ds_test.module...

swentel’s picture

@frega yeah, that patch isn't up to date anymore, working further locally. I'm hoping to get a new reroll somewhere next week.

swentel’s picture

Status: Needs work » Needs review
FileSize
55.38 KB

@frega and the rest: new patch - ze killer patch :)

* it's now possible to select a default function, ds comes with 3:
1. default core theme_field
2. theme_ds_field_reset: resets all wrappers
3. theme_ds_field_custom: uses custom settings per field

* You can define your own custom functions through hook_ds_field_theme_functions_info() eg


function hook_ds_field_theme_functions_info() {
  return array('theme_mothership_field' => t('Mothership field'));
}

function theme_mothership_field($variables, $config) {
  // Just render the items.
  $output = '';
  foreach ($variables['items'] as $delta => $item) {
    $output .= drupal_render($item);
  }
  return $output;
}

* comes with tests for nearly every possible option, so I think we're safe, also for people wanting to fiddle, you can rely on the tests if you want to submit your own patch.

Make sure you take the latest dev version of DS (either clone or wait for the next build since I've commited some other stuff today).

Open question: should I completely kill the preprocess and process functions too or just leave it like they are ? (maybe that could be an option).

* Todo:
- Nicer interface and UI, eg. the custom wrappers input field should dissapear if you do not select the custom field template.
- Run benchmarks (although I'm pretty sure we're safe here)

Alright, almost there, if all goes well, we should be able to get this out next weekend!

swentel’s picture

Status: Needs review » Fixed

I'v committed this as is (+ some extra goodies). Clone and be amazed! Release pretty imminent.

frega’s picture

Status: Fixed » Needs review
FileSize
1.79 KB

Checked it out right now - looks very nice, indeed! I have a minor request regarding the rather non-sexy custom label-issue (which is more pressing for me actually that divitis :):

Patch attached does the following:
- Change label of link to indicate where label override/custom label can be set
- If label override is in place, show the override (@todo: use JS to reflect changes à la vertical tab summary!)
- Minor UX: Added a title to the Field Template "function"-select box.

(I dared to move this to "needs review", i hope that's ok ...)

swentel’s picture

Status: Needs review » Needs work

Good points, UI changes are always welcome :)

- I like the idea of printing the label that has been overriden, however, it's now printed twice (on the left and in the link) which is redundant imo. The link could simply stay 'Label | Field template'.
- I think we should reverse the logic on the field label like this: My new label (Original: Label) - feels more intuitive (to me at least)
- I personally don't like the 'Field template type' label on the select box. 'Field template' should be enough I think (we had that originally too, but left it out because we felt it was taking up too much space). I'm not sure about the advanced help, but I guess that's because there isn't really a structured help right now anyways .. :)

Needs work because of the js for the label. I'll try to roll a patch with JS tonight.

edit: deleted my crazy idea, let's focus on the easy ones first :)

swentel’s picture

Status: Needs work » Fixed

Committed and pushed :

- label on select box (Field template)
- link is now 'Label & field template)
- Original label next to the current label
- update js trigger that updates the label in the row

maybe, if I'm crazy enough, I'll try to change the rows in such a way that it looks like in D6, but that's no priority, the faster this gets out the better :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.