use_stylesheet and use_javascript in a component

Discussion relating to version 1.3.x and 1.4.x

use_stylesheet and use_javascript in a component

Postby marcink86 » Thu Oct 29, 2009 11:05 am

Hi,
is it a bug or am I misunderstood something:

layout.php:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <?php include_http_metas() ?>
        <?php include_metas() ?>
        <?php include_title() ?>
        <link rel="shortcut icon" href="/favicon.ico" />
        <?php include_stylesheets() ?>
        <?php include_javascripts() ?>
    </head>
    <body>
        <?php include_component('menu', 'show'); ?>
        <?php echo $sf_content ?>
    </body>
</html>


_show.php in menu module:
Code: Select all
<?php use_javascript('menu.js'); ?>
<div>This is menu.</div>


menu.js is not included. Am I doing something wrong? In sf1.2 it worked for me.
marcink86
Member
 
Posts: 52
Joined: Fri Aug 28, 2009 1:57 am
Location: Gdynia, Poland

Re: use_stylesheet and use_javascript in a component

Postby marcink86 » Thu Oct 29, 2009 12:31 pm

include_stylesheets get a list of included CSS from response object and print them out.

use_stylesheet adds a CSS file to o response, so theoretically anything passed in use_stylesheet should be included to response just after a list of CSS files from response was outputted. However, how did it work in sf1.2?

I tried to add CSS in controller, in executeShow() in components which is called just before include_stylesheets(). Howeverer, it also didn't work.

Please help guys ;)~ ;-)~ :wink:
marcink86
Member
 
Posts: 52
Joined: Fri Aug 28, 2009 1:57 am
Location: Gdynia, Poland

Re: use_stylesheet and use_javascript in a component

Postby SuperDevy » Thu Nov 12, 2009 6:38 pm

I have the same problem when I try to use the sfAdminDashPlugin with Symfony 1.3

The functions use_stylesheet and use_javascript are called but there is nothing when the functions include_stylesheets and include_javascripts...
SuperDevy
Junior Member
 
Posts: 9
Joined: Sat Oct 24, 2009 8:22 pm
Location: Rouen, France

Re: use_stylesheet and use_javascript in a component

Postby Sylvio » Thu Nov 19, 2009 4:25 pm

I have the same problem with some module located in plugins.

Is it a SF1.3 bug ?

Is use Symfony 1.3 RC1
Last edited by Sylvio on Thu Nov 19, 2009 4:25 pm, edited 1 time in total.
Sylvain - Web Developper
Com-Océan / http://www.com-ocean.com
Sylvio
Member
 
Posts: 71
Joined: Fri May 12, 2006 3:36 pm
Location: Avignon, France

Re: use_stylesheet and use_javascript in a component

Postby serkanko » Sat Nov 21, 2009 6:00 am

No, this is not bug.
Changeset 17794 removed sfCommonFilter which was including css/js files you included in partials/components.

If anybody knows better way, please post here.
I copied sfCommonFilter from 1.2, and included back filters.yml and use_stylesheet() and use_javascript() working again.

S.
serkanko
Junior Member
 
Posts: 1
Joined: Mon Mar 19, 2007 5:53 pm

Re: use_stylesheet and use_javascript in a component

Postby SuperDevy » Sat Nov 21, 2009 12:05 pm

I have done a test with a simple plugin and our two problematic functions are working well with sf 1.4. But the sfAdminDashPlugin still not working using exactly the sames functions !!

I can't find the difference between those two plugins.

EDIT: Ok, the problem is in components and not in plugins.
PS: http://www.symfony-project.org/tutorial/1_4/en/upgrade#chapt er_6e784ae6af5198ee34b673eaa3e06cb4_javascripts_and_styleshe ets
Attachments
testPlugin.zip
(2.08 KiB) Downloaded 31 times
Last edited by SuperDevy on Sat Nov 21, 2009 12:30 pm, edited 1 time in total.
SuperDevy
Junior Member
 
Posts: 9
Joined: Sat Oct 24, 2009 8:22 pm
Location: Rouen, France

Re: use_stylesheet and use_javascript in a component

Postby SuperDevy » Sat Nov 21, 2009 12:55 pm

I found a solution to my problem.

I my case, the function "incude_partial" was called after include_stylesheets and include_javascripts.

Simply create a new partial template with all included css and js and use the include_partial function before in your layout.php :

Code: Select all
    <?php include_partial('sfAdminDash/header_top')?>
    <?php include_stylesheets() ?>
    <?php include_javascripts() ?>
SuperDevy
Junior Member
 
Posts: 9
Joined: Sat Oct 24, 2009 8:22 pm
Location: Rouen, France

Re: use_stylesheet and use_javascript in a component

Postby SuperDevy » Tue Nov 24, 2009 12:07 pm

Symfony team seam to have heard you :
http://www.symfony-project.org/blog/2009/11/24/final-release -candidates-for-symfony-1-3-and-1-4

Better Backward Compatibility

A few changes were reverted for better backward compatibility with symfony 1.2. Most notably, the common filter is back and will no longer be removed by the project upgrade task. However, new projects will not use the filter as this is the recommended approach.

The symfony team is eager for your feedback as we come into the home stretch for these final two major releases on the 1.x branch.
SuperDevy
Junior Member
 
Posts: 9
Joined: Sat Oct 24, 2009 8:22 pm
Location: Rouen, France


Return to symfony 1.3 and 1.4

Who is online

Users browsing this forum: No registered users and 10 guests