Welcome Guest, Not a member yet? Register   Sign In
Load Library and pass to view
#1

(This post was last modified: 01-10-2021, 01:50 AM by bystefu.)

Hello, i make a custom library for enqueue my styles. What is the strategy to use this?

Strategy 1, in controller : 


Code:
use App\Libraries\Enqueue;
$css = new Enqueue();
$css->load($arr);

But,the output will be html format 
PHP Code:
<link href="style.css" rel="stylesheet" />
<
link href="style2.css" rel="stylesheet" /> 


Or to strategy 2 , to load  in every view ? In header.php and footer.php?But i once to set once....like globally

If i load in controller, how can i pass in view?I tried with :

Code:
use App\Libraries\Enqueue;
$css = new Enqueue();


$data = [

    'css' => $this->css
];

echo view("footer",$data)

 And in footer.php (also in header.php or any view where i need) i will iniziate this class: 

PHP Code:
$css = new Enqueue();

$arr myArray();
$css->load($arr); 


But, i saw a little lazy loading on page....

I think i must to make my function to return an array, and after this i pass as variable array to viewer, and after to make a foreach...
Reply


Messages In This Thread
Load Library and pass to view - by bystefu - 01-10-2021, 01:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB