Wiki

Articles in category "tutorials", sorted by commentsX
Displaying 31-40 of 175 result(s).

Setting and maintaining the language in Application (i18n)

Created 4 years ago by olafureTutorials9 comments – viewed 49,770 times – ( +19 )
As seen in this post, Yii doesn't enforce how language is set and maintained within the session.
tags: i18n, translation

Manage (Target) Language in Multilingual Applications + A Language Selector Widget (i18n)

Created about a year ago by c@cbaTutorials9 comments – viewed 15,516 times – ( +9 )
In case of a multilingual application, one might consider it a reasonable approach to store the preferred language of the user in a session variable, and after that, every time a page is requested, to check this session variable and render the page in the indicated language. This tutorial shows a Yii-way of doing this. We implement an event handler for the onBeginRequest event; as the name of the event suggests, this event handler will be called at the beginning of each request, so its a good place to check whether a language is provided (via post, session or cookie) and set the application language accordingly. We also implement a simple Language-Selector Widget, which can render the language options as ajax-links or as a drop-down list.

Add information to Yii::app()->user by extending CWebUser

Created 3 years ago by atrandafirTutorials9 comments – viewed 57,015 times – ( +27 )
This little tutorial explains a way how you can retrieve more parameters from Yii::app()->user by adding a component that extends CWebUser and retrieves the user information from database table named User.

Display an AJAX tree from your DB using CTreeView

Created 3 years ago by François GannazTutorials9 comments – viewed 27,845 times – ( +20 )
This example uses a MySQL DB with a table named tree with the fields id, name, and parent_id. The parent_id will be NULL for root elements. The SQL is kept simple (no autoinc, no FK, etc).
tags: AJAX, CTreeView

Drills : Search by a HAS_MANY relation

Created 6 months ago by softarkTutorials9 comments – viewed 8,896 times – ( +20 )
Sometimes we get lost trying to search by a HAS_MANY relation using CActiveRecord or CActiveDataProvider. This article is a series of drills that try to describe the practical techniques of searching by a HAS_MANY relation.

Use shortcut functions to reduce typing

Created 4 years ago by qiangTutorials8 comments – viewed 27,994 times – ( +48 )
Because Yii intends to be integrated nicely with third-party libraries, it does not define any global functions. Everything in Yii needs to be addressed with full class name or object scopes. For example, to access the current user, we need to use Yii::app()->user; to access application parameters, we need Yii::app()->params['name']; and so on. While editors like textmate can help alleviate the problem of these lengthy typings, it is worthwhile to define global shortcut functions to some commonly used method calls. They will make the application code look cleaner.

By Example: CHtml

Created 3 years ago by jonahTutorials8 comments – viewed 256,327 times – ( +84 )
"By Example" cookbook pages will provide coding examples for many of the commonly used classes within Yii. We will try to provide as many usage examples as possible for keep these pages as helpful as possible.

Update content in AJAX with renderPartial

Created 3 years ago by BurzumTutorials8 comments – viewed 91,588 times – ( +50 )
The easiest way to update content in AJAX is to use the renderPartial method.
tags: AJAX

Exporting CGridView results to CSV file

Created about a year ago by RusAlexTutorials8 comments – viewed 16,637 times – ( +6 / -2 )
A few days ago, i worked for CGridView exporting functional for my client. He asked me to create a simple exporting to a CSV file a CGridView search results.
tags: cgridview, export, csv

Creating a database-driven hierarchical Structure combined with CMenu and superfish

Created 3 years ago by thyseusTutorials8 comments – viewed 29,400 times – ( +15 )
Note: Please also take a look at the newer EMenu extension. This works even better that the deprecated CDropDownMenu!
tags: menu