Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 746747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:07:34+00:00 2026-05-14T14:07:34+00:00

I am learning cakephp in an autodidact manner and I am a complete newbie

  • 0

I am learning cakephp in an autodidact manner and I am a complete newbie 🙂 I am creating a simple application. Some logic work so now I going to dive into designing views and layouts.
I read the docs and the tutorial but I could not find where to set the content of $script_for_layout.
Especially I want to set a $html->css to create link in pages to the stylesheet. I found out that I could do it in directly in the layout template but I would like to create the same link in all pages/views/layouts to the stylesheet so I hope there is a simple way, and avoid to do this in all layouts and/or controllers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:07:35+00:00Added an answer on May 14, 2026 at 2:07 pm

    You can do this with the JavascriptHelper. Load the helper via the controller’s $helpers array.

    # In your controller
    class Things extends AppController {
      $helpers = array( 'Javascript' );
    
      # ... your custom controller code ... 
    
      # OR
      public method controllerAction( ... ) {
        $helpers[] = 'Javascript';
    
        # ... additional action code ...
      }
    }
    
    # In your view
    $javascript->link( 'my_script', false );
    

    In the view code, the false parameter adds /js/my_script.js to the set of scripts loaded by the $scripts_for_layout variable. To do the same thing for CSS, the key is the same $inline parameter. Set that value to false and the CSS file will load in the head as well:

    $Html->css( 'view_css', 'stylesheet', array( "media" => "all" ), false );
    

    Take a look at the documentation for general helper info and for the Javascript helper specifically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning cakePHP 1.26. I got a HTML Select tag with some options
I am learning cakePHP 1.26. I got some sample data in a Table Testing
I am learning cakephp, and I was just doing a simple Todo list app
I'm learning cakephp for some time and it's very nice, I'm using the cake
I remember first learning about vectors in the STL and after some time, I
I am learning Python for a class now, and we just covered tuples as
I am just learning CakePHP, so excuse me I am using CakePHP 1.2.5 Auth
I am learning cakephp by myself. I tried to create a user controller with
I am learning cakePHP, everything seems alright except that I am very confused of
I am learning cakePHP 1.26. I got a Controller which got two functions. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.