facing some issue related to codeigniter url routing - codeigniter

I just want to show the url websitename/common_controller/about as websitename/about
I did like this in the config/routes.php
$route['about'] = "common_controller/about";
But it is not working. please help me.

Try writing
$route['common_controller/about'] = 'about';
if you method takes input you can write
$route['page/(:any)'] = 'method_name/$1';

Related

Using JavaScript to get the text of an element using Laravel Dusk

I'm doing automated testing using Laravel Dusk, when I do this:
$test = $browser->script('$(".page-sidebar-menu").text();');
dd($test);
It returns array of null, but if run $(".page-sidebar-menu").text(); in a browser, it returns all text inside that class.
Where I go wrong in here? Please help if you know.
Okay it's wrong of me to asked this, I not include return inside script
it should be like this
$test = $browser->script('return $(".page-sidebar-menu").text();');
dd($test);

How to redirect to url in laravel 5.0

i am using laravel 5 on local on window ..i am trying to redirect the page to some external url..but nothing seems to help me..
i tried
return \Response::make('',302)->header('Location','http://site2');
return redirect()->away("http://site2");
\Redirect::to('http://site2');
header('Location: http://site2');
but none of them working..gives no response..
Something like this :
return redirect()->away('http://site2');
Make sure you also add a return (i.e. return $this->checkSession();) in start().

Ajax request POST returns 403 error, GET returns 200 ok on same url

I'm trying to set up a prestashop webshop and I bought a theme to customize it. Instalation works great, but when reaching the live edit module of the theme I ran into a problem: after customizing the layout I tried to save my modifications, but it returns with 403 error. I've tried to debug it, I've contacted my hosting, I've contacted the developer of the theme, but noone can help me. In the error logs doesn't appear anything regarding this issue. The developer says it is tested on multiple hosts, and it works great. My host says they can't do anything if there is no error message in the logs.
I've managed to circle down the issue a little bit. There is a larger sized parameter(it contains all new configurations) which if I disable to be sent, then I get the following error: "Your hosting provider has set a non-standard or too little value of parameter LimitRequestLine in httpd.conf. Set the default setting value of parameter LimitRequestLine in httpd.conf, please." This error I receive on post and get aswell.
This parameter can be the source of my problem if the http call is through ajax post? Or there is more this issue?
I'm trying to solve this issue for 3 months now, I've spoken to the hosting firm, I've spoken to the developer of the them, I've searched a lot of forums but found no answer to this. I'm desperate to get any help on this matter.
It looks like I solved the issue with the following codes:
/public_html/modules/ixtengine/js/cpanel/cpanel.min.js
... ,$.ajax({type:"POST",url:cpfuncurl+previewfun,data:{ ...
replaced by
... ,$.ajax({type:"PUT",url:cpfuncurl+previewfun,data:{ ...
and
... ,$.ajax({type:"POST",url:cpfuncurl+savefun,data:{ ...
replaced by
... ,$.ajax({type:"PUT",url:cpfuncurl+savefun,data:{ ...
/public_html/modules/ixtengine/cpanel/functions/upload.savepf.php and /public_html/modules/ixtengine/cpanel/functions/upload.previewwid.php
...
$theme = Tools::getValue('theme');
$conf = Tools::getValue('conf');
$skin = Tools::getValue('skin');
$skinid = Tools::getValue('skinid');
$token = Tools::getValue('token');
...
replaced by
...
$put_vars=array();
if($_SERVER['REQUEST_METHOD'] == 'PUT')
{
parse_str(file_get_contents("php://input"),$put_vars);
$theme = $put_vars['theme'];
$conf = $put_vars['conf'];
$skin = $put_vars['skin'];
$skinid = $put_vars['skinid'];
$token = $put_vars['token'];
}
else
{
$theme = Tools::getValue('theme');
$conf = Tools::getValue('conf');
$skin = Tools::getValue('skin');
$skinid = Tools::getValue('skinid');
$token = Tools::getValue('token');
}
...
This solution is particulary for the ixtengine module for some hosts where POST returns 403 error so I can't be sure if this method will work for someone else running into this problem, but it works for me.

get the frontend theme path in magento admin

In my Magento module i upload a CSS file in the backend to use it in my front
I tried this :
Mage::getSingleton('core/design_package')->getSkinBaseDir()
But it gives different path (admin/front)
In my Block , I got this :
C:\wamp\www\ce_1.6.2.0\skin\frontend\default\default\
And in my Adminhtml/Controller (saving the file) I got this :
C:\wamp\www\ce_1.6.2.0\skin\adminhtml\default\default
How can I get the same path (front) in the Block and in the Controller ?
Thanks
just force it to the frontend :
Mage::getSingleton('core/design_package')->getSkinBaseDir(array('_area' => 'frontend'))
I'd like to offer and alternative to Rastaking's answer that will return a URL path rather than a file path:
Mage::getModel('core/design_package')->getSkinUrl();
This will return something like:
http://www.yourdomain.com/skin/frontend/your_package/your_skin/
Hope this helps, anyone looking for a similar solution.
You can try this:
Mage::getSingleton('core/design_package')->getSkinBaseDir(array('_area' => 'frontend','_package'=>'rwd','_theme'=>'default'));

How to use params with slashes with Sinatra?

Playing with sinatra, I'm stuck on a little problem : when I use params with slashes, it confuses the router engine. So is there a nice way to handle this kind of param without having to encode it ?
The code looks like
get 'add/:url' do
#....
end
And I intend to get something like /add/http://sctackoverflow.com/ working
Did you try to use splat parameters?
Something like:
get '/add/*' do
protocol = params[:splat].first
address = params[:splat][1..-1].join('/')
url = protocol + "//" + address
end
thank you, I haven't heard about splat parameters and it works perfectly for this case. Indeed, I've looked into the documentation and I found even shorter using capture parameters and regular expressions :
get %r{/add/(.+)} do
url = params[:captures]
end
or use:
url = request.fullpath[5..-1]

Resources