I'm trying to learn how to develop my website using Laravel 5.
Now i'm working on the languages of the site, but I have some questions that I hope you guys might know how to solve.
I know that the Location service helps a lot when translating the site, but I want something a little more complicated. I want to put a <select></select> tag at the top of my header where the user will have the option to change to another language.
Right now, I have already created the following folders that will have all the information to be translated.
-resources
-lang
-en
messages.php
-es
messages.php
Each messages.php file has the complete directory of the information to be translated.
I know how to do this using pure php ($_SESSION) and jQuery, but I have no idea how to do this with laravel.
I would like that the website has will look like this:
/[about]
/[contact]
/en
/en/[about]
/en/[contact]
/fr
/fr/[about]
/fr/[contact]
Hope you guys help.
Thanks.
EDIT
I just found a laravel package which can help to manage this kind specific issue in the proper way.
The package name is Laravel Localization and it's pretty easy to use.
Link here
Use the directions from here: http://laravel.com/docs/master/localization
Route::get('{locale}/{page?}', function ($locale, $page == '') {
App::setLocale($locale);
// your code
});
And as for the change of the language from a drop down, just redirect the users based on their choice with java script.
Related
I went through similar questions on SO but didn't get my answer. So I thought to put this together in a more simpler way here.
I have a website with url like :
http://domain.com/user/user-name [ here user-name is dynamic and changes for every user, pretty obvious. ] - This right now works perfectly fine.
Next :
I need to show pages as below for users in a url like :
http://domain.com/user/user-name/about
http://domain.com/user/user-name/contact
http://domain.com/user/user-name/posts
etc
FYI : I'm using ultimate member plugin to manage user profiles.
So I need to know how can I crate separate page for each of the above mentioned URL's custom to each of the section like about / contact / posts.
though I'm working with wordpress since quiet a time now but this problem makes me feel newbie to it. Please tell me step wise on how can I achieve this.
I've spent 2 days already working out various things.
Thanks.
Take a look at the plugin called "Pods". It implemented the "URL Regex" as you required.
https://wordpress.org/plugins/pods/
I have created few applications in core php and now decided to move to CakePHP hoping to get better control over things. i was able to follow the cookbook blog example successfully but i understand angularjs well enough and love to work with it. i am following below article
https://github.com/hantsy/angularjs-cakephp-sample/wiki/2-rest-api
to make an api which can reply to my angularjs calls but when i call the page
http://localhost/posts.json at the end i get 404 : page not found error. not sure what is going on . I did not use the bake commands but i do have the Post model and controller well placed. Seems like there is something small thing i am missing may be in routing file . can you please help me overcoming this . Thanks for support !
pawan
Please add your cakephp folder name where your main app folder resides in url and after that it will look like this:
http://localhost/"your cakephp folder"/posts.json
Hope it helps.
Thanks
I am somehow confused to analyse a project. Client says "I need an admin panel using PHP that create subdomain on wizard", i.e like he wants www.domain.com/sub1, www.domain.com/sub2, www.domain.com/sub3 etc. each sub domain may contain different header, menu, content, footer etc. I am really confused in "How do I make PHP admin panel that creates a directory and files for each subdomain?". I hope you got it, otherwise I am ready to discuss it more.
Thanks.
Hope you have something on this:
http://php.net/manual/en/function.mkdir.php
http://php.net/manual/en/function.fwrite.php
Why making a directory for each "domain"? You can use .htaccess and a database.
So I've built my site in Code Igniter and there are a number of pages where I feel it'd be easiest if the client could edit the content inline - much like what MojoMotor offers.
I'm not interested in using mojomotor but I wondered if anyone had done anything like this for their code igniter project?
As an idea of how it could work:
I was thinking that the client admin user could login to the normal custom built admin CMS area. After logged in, with session set, they can browse out to the public site for selected pages.
These pages will have a check for that admin session built in and if it's present, it can include a js file, which will overlay an admin banner and somehow enable the fields (perhaps content divs with a certain id or class relating to the corresponding table/field in DB) for editing.
--EDIT--
I've seen quite a few js inline editors around. I guess my confusion is over how best to integrate them with my database and controllers - i.e. idea of having the div id/class somehow map to the db field.
The bottom line is that MojoMotor is a CodeIgniter app and not a library. Therefore trying to work the code into your existing CodeIgniter project is not really an option.
But if you're willing, you can integrate your CodeIgniter project into MojoMotor and have the benefits of both. Here is a series of articles written on how to do this.
This is one example of the code you are looking for . You'll have to adapt the method for use with CI
I made a component and now I want to customize the link for it.
I already wrote the router.php.
The link to the component view (if I use the JRoute function of course) now looks good, except for the first part, which looks like :
http://www.example.com/en/component/componentname/...
don't mind the "en", it's there cause I use JomFish to manage more languages on my site.
I want to transform "/component/componentname/" to "/myString/" for example.
I can't use the menu for this, cause my site displays info from a database, linking this many sites to my menu is impossible.
The only solution I found requires the changing of the Joomla JRoute function (I found only a suggestion, not how it's done :( ).
What about using mod_rewrite to rewrite your url?
Basically you put the rewrite rules into your .htaccess file and Apache will handle the rest.
There is a great guide that teaches you all about it on http://www.htmlist.com/how-to/a-simplemod_rewrite-tutorial/