Comments

vlad.dancer’s picture

Status: Active » Needs review
StatusFileSize
new1.4 KB

Moved code from theme_toolbar_toggle() to preprocess_toolbar_toggle()

podarok’s picture

Status: Needs review » Needs work
+++ b/core/modules/toolbar/toolbar.module
@@ -47,6 +47,7 @@ function toolbar_theme($existing, $type, $theme, $path) {
     ),
+	'template' => 'link',
   );

no tabs! use whitespaces!

vlad.dancer’s picture

Status: Needs work » Needs review
StatusFileSize
new1.4 KB
podarok’s picture

Status: Needs review » Reviewed & tested by the community

good work!
thanks

podarok’s picture

Status: Reviewed & tested by the community » Needs review

patch does not apply against latest merge_chx_sandbox branch

git apply --check 1779104-toolbar-toggle-3.patch
error: patch failed: core/modules/toolbar/toolbar.module:47
error: core/modules/toolbar/toolbar.module: patch does not apply

need reroll

podarok’s picture

Status: Needs review » Needs work

woops
status

podarok’s picture

Component: Code » Twig templates
Status: Needs work » Fixed

commited #3 into 8.x branch

Status: Fixed » Closed (fixed)

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

fabianx’s picture

Assigned: vlad.dancer » jenlampton
Status: Closed (fixed) » Needs work
Issue tags: -code sprint drupal night ua 2012

Re-opened as it was not merged to front-end branch, yet and removing theme functions should probably not be done.

@jenlampton: Could you take a look at the patch and ask author to re-roll properly?

Best,

Fabian

vlad.dancer’s picture

@fabianx

There is one thing that i don't know how to resolve it.
Currently, as doc at pixelmord sandbox said: "Don't remove theme func", becouse we want to use theme func. in another phptemplate themes. And in current toolbar_toolbar i want to define "template => link" for twig equivalent link.twig (template consolidation), but when i do, phptemplates try to fing link.php.tpl and of couse there is no such template) ?

What should i do? Maybe there is existing discussion about it?

fabianx’s picture

This will be resolved soon as we move all our work over to the modules directly.

We are that far in core now :).

http://drupal.org/node/1696786#comment-6576850

And the template => 'file' seems to work fine even if another theme is used, but needs more investigation.

vlad.dancer’s picture

Thx for information.
It seems in front-end branch i got this error when do one.

Warning: include(): Failed opening 'core/modules/toolbar/link.tpl.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in theme_render_template() (line 1418 of core/includes/theme.inc).

vlad.dancer’s picture

I found solution to make this theme func. working with both engines.
Replace implementation of toolbar_toggle render.
Before:

  // Add an anchor to be able to toggle the visibility of the drawer.
  $build['toolbar_toggle'] = array(
    '#theme' => 'toolbar_toggle',
    '#collapsed' => _toolbar_is_collapsed(),
    '#attributes' => array('class' => array('toggle')),
  );

After:

  // Add an anchor to be able to toggle the visibility of the drawer.
  $link_element = array(
    'options' => array(
      'query' => drupal_get_destination(),
      'html' => FALSE,
      'attributes' => array('class' => array('toggle')),
      ),
    'path' => 'toolbar/toggle',
  );

  if (_toolbar_is_collapsed()) {
     $toggle_text = t('Show shortcuts');
  }
  else {
    $toggle_text = t('Hide shortcuts');
    $link_element['options']['attributes']['class'][] = 'toggle-active';
  }
  $link_element['text'] = $toggle_text;
  $build['toolbar_toggle']['#type'] = 'markup';
  $build['toolbar_toggle']['#markup'] = theme('link__toolbar_toogle', $link_element);

From toolbar_view() (this code is transitional stage of removing renderable arrays)

It's ok when this link renders in phptemplate, but in twig there are errors. This errors comes from link.twig!
Becouse in theme_link we doesn't have $variables['attributes'] unlike in link.twig!

So question is where this error will be fixed? In theme_link or link.twig?

vlad.dancer’s picture

Status: Needs work » Active
vlad.dancer’s picture

Status: Active » Needs review
StatusFileSize
new1.5 KB

This patch add new variable for link also fix problem from comment #9. But it throws errors in phptemplate themes.

Also this theme_toggle_toolbar is point where we need to add new Attributes.
Also if we would remove drupal render style from toolbar_view() we could replace theme_toolbar_toggle by theme('link__toolbar_toggle', $vars);

podarok’s picture

Status: Needs review » Reviewed & tested by the community

#15 looks good for me
but before commit we should decide what to do with "not found" *.tpl.php templates in such cases

podarok’s picture

Status: Reviewed & tested by the community » Fixed

#15 commited / push to front-end

Thanks!

jenlampton’s picture

Status: Fixed » Active

this file is stil missing from the front-end branch, can you push again?

podarok’s picture

#18 what file?

jenlampton’s picture

toolbar-toggle.html.twig is not in the core/themes/stark/templates/toolbar directory.

I expect that this patch was committed and just not pushed?

podarok’s picture

#20
we are not using toolbar-toggle.html.twig
we are using link.html.twig here http://drupalcode.org/sandbox/pixelmord/1750250.git/blob/5d7dd04f00eff12...

podarok’s picture

Status: Active » Fixed

status

jenlampton’s picture

Status: Fixed » Active

Ah, okay. Then we'll need a temporary file that includes link.html.twig instead with a @todo and a link to the core issue #1595614: [meta] Remove all the theme functions and templates in core that simply output a link. Replace with #type 'link' render arrays

See textfield.html.twig for an example of how this is done - but the Twig template should look something like this:

{#
/**
 * @file
 * Default theme implementation to display a whatever.
 *
 * Available variables:
 * - text: The link text for the anchor tag.
 * - path: The internal path or external URL being linked to, such as
 *   "node/34" or "http://example.com/foo".
 * - attributes: Remaining html attributes for the containing element.
 *
 * @see template_preprocess
 * @see template_preprocess_toolbar_toggle
 *
 * @ingroup themeable
 */
 @todo: remove this file once http://drupal.org/node/1595614 is resolved.
#}
{% include "core/themes/stark/templates/theme.inc/link.html.twig" %}
vlad.dancer’s picture

Status: Active » Needs review
StatusFileSize
new1.16 KB

Added
- temp template
- new template name to theme func in hook_theme
- added @todo in template

podarok’s picture

Status: Needs review » Fixed

#24 commited / pushed to front-end

Thanks!

jenlampton’s picture

Status: Fixed » Needs work

There are still a few problems with the file in the front-end branch:

- missing available variables in docblock
- missing include (still shows anchor tag?)

comments on anchor tag (though about to be removed)
- whitespace controllers around classes (they should never be on classes)
- missing whitespace controller on left of attributes (should always have one on attribtutes)

It looks like this line was just copied from link.html.twig, so I'll update that file too. Sorry for the confusion.

jenlampton’s picture

Just for reference, I updated the template file in front-end to be the following:

{#
/**
 * @file
 * Default theme implementation for a toolbar drawer's visibility.
 *
 * Available variables:
 * - text: The translated link text for the anchor tag.
 * - attributes: Remaining html attributes for the containing element.
 * - attributes.class: HTML classes that can be used to style contextually
 *     through CSS.
 * - path: The internal path or external URL being linked to, such as
 *   "node/34" or "http://example.com/foo".
 * - options: Additional options, with the following elements:
 *   - options.attributes: An associative array of html attributes to apply
 *     to the anchor tag. If element 'class' is included, it must be an
 *     array; 'title' must be a string; other elements are more flexible,
 *     as they just need to work in a call to
 *     drupal_attributes($options['attributes']).
 *   - options.html (default FALSE): Whether $text is html or just plain-text.
 *     For example, to make an image tag into a link, this must be set to
 *     TRUE, or you will see the escaped html image tag. text is not
 *     sanitized if 'html' is TRUE. The calling function must ensure that
 *     text is already safe.
 *   - options.language: An optional language object. If the path being
 *     linked to is internal to the site, $options['language'] is used to
 *     determine whether the link is "active", or pointing to the current
 *     page (the language as well as the path must match). This element is
 *     also used by url().
 *   - Additional options elements used by the url() function.
 *
 * @see template_preprocess
 * @see template_preprocess_toolbar_toggle
 *
 * @ingroup themeable
 */
 @todo: clean up url() once http://drupal.org/node/1812562 is resolved.
 @todo: remove this file once http://drupal.org/node/1595614 is resolved.
#}
{% include "core/themes/stark/templates/theme.inc/link.html.twig" %}

steveoliver’s picture

vlad.dancer’s picture

Status: Needs work » Postponed (maintainer needs more info)

Thanks for #26, 27!

About 26. Thx a lot for your job! I think there is no difference now either copy code from link template or use include (if this situation temporary and we want replace template by theme('link'))

About #28 - there is no room where we can easy call theme('links'), actually - there is, but also we need refactoring of render arrays output style (see comment #13).
Previous method that i supposed was add 'template' => 'link'

steveoliver’s picture

Status: Postponed (maintainer needs more info) » Needs review
Issue tags: +theme system cleanup
StatusFileSize
new3.95 KB

This is what I'm talking about (attached).

Depends on #1 in #1825820: theme('link').

steveoliver’s picture

Last patch was missing an important line that switched the toolbar-active class on and off.

To the point:

1. Apply this from #1825820: theme('link')
2. Apply this from #1825828: theme('toolbar')
3. That's how I think toolbar should work.

Sorry for all the posts. I'm trying to keep patches on their own topics.

podarok’s picture

#31 please better use
[#topicID-commentNUM] as #1779104-31: Convert theme_toolbar_toggle to twig for Your comment to point to right place(issue node + comment) of a patch

steveoliver’s picture

Will do, podarok.

podarok’s picture

#33 what is here to review?
i`d lost myself :(

steveoliver’s picture

podarok: see #1825828-3: theme('toolbar') for full patch for toolbar.

podarok’s picture

bad comment
sorry

steveoliver’s picture

Issue tags: +Twig
StatusFileSize
new116.92 KB
new122.07 KB

This patch removes theme('toolbar_toggle') and replaces it in theme('toolbar') with an implementation of theme('link').

It fixes the toolbar toggle issue I noticed (Hide shortcuts and Edit shortcuts links).

Before:

d8tts-toolbar-toggle-1779104-fixed.png

After:

d8tts-toolbar-toggle-1779104-broken.png

steveoliver’s picture

Patch would be helpful.

jessebeach’s picture

Hi all, I just wanted to mention that the toolbar theme issues are being addressed in the responsive toolbar patch. I just switched from tpl to twig in the latest patch.

#1137920-282: Fix toolbar on small screen sizes and redesign toolbar for desktop

I would suggest closing this issue as a duplicate or at least postponing it. I'd like to avoid you all spending time on unnecessary work here.

fabianx’s picture

Status: Needs review » Closed (duplicate)
johnnydarkko’s picture

Component: Twig templates » Twig templates conversion (front-end branch)
Status: Closed (duplicate) » Needs work

Admin Toolbar overlay isn't showing in stark.

johnnydarkko’s picture

Status: Needs work » Closed (duplicate)

Accidentally reopened this one... meant to post the previous comment on #1825828: theme('toolbar')

Project: » Lost & found issues

This issue’s project has disappeared. Most likely, it was a sandbox project, which can be deleted by its maintainer. See the Lost & found issues project page for more details. (The missing project ID was 1750250)