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 7432237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:25:36+00:00 2026-05-29T09:25:36+00:00

I tried several ways to apply the .css and .js files to the view

  • 0

I tried several ways to apply the .css and .js files to the view php file. (1) The first way is as shown below:

<head>

<meta charset="UTF-8" />
<?php echo html::meta('viewport', 'width=980'); ?>

<title>A-TRACK Tutoring</title>
<?php echo html::link('http://fonts.googleapis.com/css?family=Open+Sans:300,400,700',
'stylesheet','text/css', FALSE);?>

<?php echo html::link('media/css/atrack.css',
'stylesheet','text/css', FALSE, 'all');?>
</head> 
......
</html>

(2) The second way is as shown below:

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=980" />

<title>A-TRACK Tutoring</title>
<?php
    if(isset($css)){
    foreach($css as $type => $file){
?>
<link type='text/css' href='<?php echo $file ?>' rel='stylesheet' />
<?php
    }}
?>
......
</head> 

and in the index action of the controller

public function action_index()
{
        $view = View::factory('singleanswer/index');
        $view->css = array(
            'normal' => 'media/css/atrack.css',
            'normal' => 'http://fonts.googleapis.com/css?family=Open+Sans:300,400,700',
    ); 
        // Render the view
        $this->response->body($view);

}
} // End Welcome

Neither of them works. Does anyone know the reason ? Thanks.

  • 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-29T09:25:37+00:00Added an answer on May 29, 2026 at 9:25 am

    In example 2, you are writing over the atrack.css value by using the same key twice in the array.

    Change your controller like this:

    public function action_index()
    {
            $view = View::factory('singleanswer/index', array("css" => array(
                Url::site("media/css/atrack.css"),
                'http://fonts.googleapis.com/css?family=Open+Sans:300,400,700',
            ));
            // Render the view
            $this->response->body($view);
    
    }
    

    And update your view to this:

    <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=980" />
    
    <title>A-TRACK Tutoring</title>
    <?php
        if(isset($css))
        {
            foreach($css as $file){
                    echo "<link type='text/css' href='{$file}' rel='stylesheet' />";
            }
        }
    ?>
    ......
    </head> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tried several ways to open an OTB file (otb files is like dat
Can this code be shorten in some way? I've tried several ways to compact
I have tried several ways to login to a website through java. I have
I tried several ways in the session bean, like: @Resource private SessionContext ctx; OR
I've tried several ways to update an object in my database. I've also read
I have tried several ways to cast a float to an int, what I
I got a problem stuck me few days, tried several ways still can't figure
I have tried several ways to get MoveFileEx working with the DELAY_UNTIL_REBOOT flag without
I have gone through most of the code here and tried several ways to
What's wrong with this? .serialize() returns nothing. I've tried several ways to do this,

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.