Hello friends, my problems is the following .. I have defined a MVC logic in which at the beginning I parsed the url with htaccess. for the url to be defined in the following way (controller / methodo / parameters1 / parameter2).
Well this is accomplished render with call_user_func_array .. everything is well executed methods there is no problem with that ..
all this is executed from the index .. instancio the object that does all this and render to the controllers
<?php
//index.php
$aplicationMVC= new aplicationMVC();
$aplicationMVC->startApp();
I have a class called Views that is responsible for rendering the views this class uses the output functions of the buffer ob_star () ...
<?php
class views{
function render($view){
ob_Start();
$parametros //esto tiene una logica pero paso los parametros
inlcude $view
$asd =ob_getcontent();
ob_end_clean();
echo $asd;
all right up there ..
My problem comes when the controller methods have parameters ... every time I add a parameter to a function of the controller ... I have to go back to a directory when in the views I call the files of the styles and javascripts. . Do you get it? now I put an example code
<?php
require("views.php);
class homecontroller{
public function funk()
{
$views = new views();
$views->mostrarvista("vista");
}
public function funk2($parm,$parm2)
{
$views = new views();
$views->mostrarvista("vista2");
}
}
?>
this is what happens in the view of the second function when I define all styles I have to go back two directories in all the calls css files js images and in all the links to the web etc .. (../. ./)
I do not know what will happen a priori ... I have tried to fix it in the parent controller so that I do not define methods in all the controllers but I was embolonka the filly xd, if anyone knows what is happening exactly or if I have already dealt with the problem and has a good solution I would be very grateful for the help.
What really happens is that when I call the files it is concatenated with the current url that would be (controller / method / parameter / parameter2) + the directory of the assets / css / app.css files .. at least that shows me in the developer help interface in the network section in the file url
in the case of the image the controller is home the method index and asd is the parameter of index .. the other is the url of the file css Does anyone know how to solve this in a simple way .. or do I have to calculate the backdirs in each function and send a variable in sight?