Development

#2114 ([PATCH] Setting position for Stylesheets and Javascripts in view.yml)

You must first sign up to be able to contribute.

Ticket #2114 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 month ago

[PATCH] Setting position for Stylesheets and Javascripts in view.yml

Reported by: Andrejs.Verza Assigned to: fabien
Priority: minor Milestone: 1.2.0
Component: view Version: 1.1.0 DEV
Keywords: assets, position, javascript Cc: erik@wanderings.us
Qualification: Ready for core team

Description

I figured out how to set position for stylesheets defined in view.yml:

default:
  stylesheets:
    - general
    - x2.widgets.Tabs.css: { position : first }

I thought it should also work for Javascripts, which are more important for me, because of the prototype-dependent Javascript libraries:

default:
  javascripts:
    - general
    - x2.widgets.Tabs.js: { position : last }

... but, unfortunately, it does not work because both Stylesheets and Javascripts are parsed differently in sfViewConfigHandler->addHtmlAsset() method, which in turn doesn't care about positions for Javascripts.

Those, who wonder about ".css" and ".js" extensions in the definition blocks, look here: #2113.

Attachments

sfViewConfigHandler.class.php (10.5 kB) - added by Andrejs.Verza on 08/20/07 12:18:52.
sfViewConfigHandler.javascript-position.diff (0.8 kB) - added by KRavEN on 01/23/08 18:15:09.
Diff against symfony 1.0.11
sfViewConfigHandler.class.php.diff (1.0 kB) - added by e.meitner on 02/25/08 16:54:16.
Unified diff that works, w/ cleaner formatting

Change History

08/20/07 12:17:45 changed by Andrejs.Verza

I am adding patched sfViewConfigHandler.class.php file here. Some remarks on this patch: 1) $delete and $delete_all and $omit variables not used anywhere within the method; 2) $options variable not used in Javascripts parser cycle, because AddJavascript? takes two parameters, unlike AddStylesheet?, which takes three of them; 3) unset($optionsposition?) not needed in the Javascripts parser section, because $options are not used.

Hope to see this implemented in 1.0.7. ;)

08/20/07 12:18:52 changed by Andrejs.Verza

  • attachment sfViewConfigHandler.class.php added.

08/20/07 12:19:16 changed by Andrejs.Verza

  • summary changed from Setting position for Stylesheets and Javascripts in view.yml to [PATCH] Setting position for Stylesheets and Javascripts in view.yml.

08/20/07 12:22:50 changed by Markus.Staab

Another note about the position feature:

Sometime it is not enough to have only "first" and "last" because of several depending javascript files. Maybe here should also be integer values possible..

@Andrejs: The Symfony-Devs prefer patches/diffs

08/20/07 22:51:31 changed by Andrejs.Verza

Well, I'd like diff, please show somebody how do I do diff?

10/01/07 08:08:44 changed by dwhittle

  • qualification set to Patch rejected, quality issue.

diff file1 file2

01/23/08 18:15:09 changed by KRavEN

  • attachment sfViewConfigHandler.javascript-position.diff added.

Diff against symfony 1.0.11

01/23/08 18:15:54 changed by KRavEN

  • version changed from 1.0.5 to 1.0.10.
  • qualification changed from Patch rejected, quality issue to Unreviewed.

Diff against symfoyn 1.0.11 attached

02/25/08 03:34:03 changed by e.meitner

  • cc set to erik@wanderings.us.
  • keywords changed from assets, position to assets, position, javascript.
  • version changed from 1.0.10 to 1.0.11.

Upon re-reading this section [ http://www.symfony-project.org/book/1_0/07-Inside-the-View-Layer#File%20Inclusion%20Configuration ] in the book I tried to use the 'position' option as the docs seemed to indicate this was possible. I found that in order to make use of some excellent JS libraries(eg. Control.Modal) I needed finer gained control of the inclusion order of the JS files. Independently I altered sfViewConfigHandler.class.php in my 1.0.11 code as others did above. I would very much like this to be part of the next release of 1.0.x rather than to be clarified in the docs.

02/25/08 16:54:16 changed by e.meitner

  • attachment sfViewConfigHandler.class.php.diff added.

Unified diff that works, w/ cleaner formatting

02/26/08 04:57:52 changed by Carl.Vondrick

  • version changed from 1.0.11 to 1.1.0.
  • type changed from defect to enhancement.
  • qualification changed from Unreviewed to Ready for core team.

This is a feature and cannot be added to 1.0, so moving to 1.1.

06/23/08 03:38:28 changed by dwhittle

  • milestone set to 1.2.0.

Can you confirm this is still an issue in 1.1, and if so update the patch.

08/31/08 21:31:55 changed by FabianLange

  • status changed from new to closed.
  • resolution set to fixed.

no response on this ticket and according to my checks this works ok in 1.1 and 1.2