How to debug
when I click this
<li>Promotion</li>
It'll go to en/promotion page
but after I do somthing not sure what I do It change to /promotion
any idea how to debug this
You can use Laravel's URL Default Values for this. It allows you set a default value like the 'en' so you don't have to write it everytime and you would be able to use url('test2') to get en/test2
I'm guessing you want to be able to have different languages in your website, but don't want to manage this manually on every redirect. You either need to write your own middleware to do this or use a package.
I would recommend the latter. In my projects I'm using this one, there are others out there, you can find one that suits your needs.
This package has the ability to do exactly what you want - it rewrites your URL to include the language parameter.
Related
We're using Go (Buffalo) to serve up both an API and the static assets for a Single-Page Application (SPA) that uses Svelte and Routify.
However, I'd like to have certain routes (e.g. "/auth/login") be ignored by Routify and instead go to the Go / Buffalo server, for handling those requests.
Is there a Routify setting for that?
I see the ignore build config, but that seems to be for telling Routify to ignore certain files when building the list of routes, not ignoring certain URL paths.
(If I have to, I might be able to get our /auth/login call to work as an XHR call, then actually manually redirect the browser based on the response, but it would be nicer/simpler to simply allow the browser to go to /auth/login directly.)
UPDATE: Apparently going to /auth/login directly (e.g. in a new tab) does what I want. It's just clicking a link in the SPA that gets intercepted by Routify. So my question still stands, though slightly altered:
Is there a way to tell Routify not to intercept links to certain URL paths, but to simply let the browser go to that URL (leaving the SPA)?
The target attribute on a link tag does what I was after. Hooray for finding the appropriate documentation!
If you want to use anchor's default navigation behaviour you can do so by adding the target attribute.
Routify will ignore all anchors with target attribute.
Source:
https://www.routify.dev/guide/navigation
So in my case, I needed to do this:
Login
I believe Smarty templates has functionality built in that allows you to manage your site URLs from a config file so if something gets moved, you only have to update the URL in one place. Does this sort of functionality exist in CodeIgniter? If not, any pointers or examples on how/where to add it?
For example:
Instead of hard-coding the link it would be: Settings
But where would you want to set $links so that it was available everywhere? Or is it really best to just hard code them?
Take a look at the config class. It allows you to make custom config files.
It's not entirely made for URL's but you sure can use them.
The base url should be basically right at the start of /app/config/config.php, where app is the name of your codeigniter application folder. You access it through calls to the base_url() function.
Yes, it's called Routes, configuration located at config/routes.php. Documentation
If you ask about the rendered html of the links, then your best bet would be using site_url() in conjunction with constants, for example site_url(URL_SETTINGS);, there is no built in functionality for that, but I can say I don't think that is necessary as it would be used too rarely, but it would influence performance every single load.
I am looking for a more advanced user agent detection library for Codeigniter.
I want to add short tags for OS, Browser and Browser version to the body tag so
that I am able to write CSS that is gear towards different browsers and platforms.
Like this:
<body id="Win7 IE9">
Right now the default agent detection library for CI produces this:
<body id="Windows 7 Internet Explorer 9.22.2">
How can I "shorten" the response?
This is want I am looking to achieve: http://www.contao.org/en/blog/forget-about-browser-hacks-in-contao-210.html
Thankful for all input!
I don't think that user agent library is bad. It just do what it is supposed to do.
Maybe you should build a small helper or extend the user agent library, this is really simple task (you should look at agent->browser(), agent->version, agent->platfrom() etc.)
Despite what Contao says, these are browser hacks. Better way is to build your style sheets and/or javascript the right way (without this type of hacks). I don't ever needed different stylesheets (or browser specific classes) for different browsers.
I see what you are trying to do. To get away with this using CodeIgniter you'll have to basically rewrite the user agent library to return your shorter user agent strings (its time consuming but not too difficult)(the four user agent arrays are in: system/libraries/user_agents.php).
Its been more than a year since this question was asked but i am sure it will help someone in future. User agents names are defined in ./application/config/user_agents.php file in an associative array format you can change the value of array with the one you want.
Note: Changing the value in config file will reflect in the entire application. If you want to change in a particular area of application i would suggest to create your own function.
Try this
$this->session->userdata['user_agent'];
I have created a controller named «wizard» that should get a parameter and then, depending on this parameter, do this thing or another thing.
I can do this easily with the url http://mysite.com/wizard/index/index/action/cutting. That should give the action parameter with the value «cutting» to my indexAction of my IndexController.
But what I'd really want is to have the same thing but with the url:
http://mysite.com/wizard/cutting
Where «cutting» is the parameter. If I want to handle this with my indexAction of my IndexController.php, what should I change on the config.xml? (well, I'm supposing that I can set this on the config.xml file, but don't know how).
Btw: I know I can pass something like ?action=cutting, but that's not what I want...
Thanks!
You have to enable mod_rewrite on your server (if you are using apache) and enable "Use web server rewrites"
Here's a good tutorial explaining the issues.
i'm in the process of adding a US site to my current UK site. I'd like to do this as transaprently as possible so that we don't lose any traffic to existing links. We're currently running this under version 1.4.1.1 of Magento on a shared hosting setup.
The new website (US) will be essentially the same as the current (UK) site, but with US Dollar pricing instead of Pound Sterling.
We currently have a GeoIP setup whereby visitors are redirected to either UK or US site whilst utulising the same URL. This essentially means that we have switch statements in our index.php to indicate what run code to use.
Here's my question:
what's the best way of selecting/overriding the GeoIP selection via the standard store switcher selector dropbox? Both websites are being populated in the dropbox, however, since both are utilising the same URL (www.example.com/boutique) the default one is the only one that's being selected.
I've also tried the &_store= as well as the &_website= arguments with no success.
Any ideas? are URL rewrites in .htaccess the answer? if so, any ideas as what to use?
P.S. this is the method that's pretty much being followed however my aim is to let users override their location-specific website (e.g. US) if necessary:http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/navigation/multiple-website-setup#multiple_website_setup_for_useuuk_storespricing
Have you tried using a getUrl() method to build the store arguments for you? It can help clear up those little misunderstandings, for example I'm pretty sure the store parameter is supposed to have three underscores but cannot really remember so I use the function instead.
The best way to over-ride is to have a little php program, e.g. 'countries.php' that sets a cookie depending on the country code that you choose or 'auto' to test regular geoip. Then in your index.php have an 'if cookie then use cookie code else use geoip code'. Naturally the cookie can only be set by your test program.
And yes, you only need set 'website' not 'store'. There is no benefit in your US customers being able to see your UK prices (and vice-versa) so don't even bother with setting up a frontend drop-down. Or, if you really want, you can have rest-of-the-world customers choose their currency/website and put your own cookie-setting code in the header for them, with a couple of nice flag icons.