Wiki articles in category How-tos

Showing 41-60 of 292 items.

Configuring controller access rules to default-deny

Created 13 years ago by Steve Friedl, updated 10 years ago by nsanden.

Starting with the blog tutorial, Yii developers are familiar with the notion of access rules defined in the controller, where the actions are allowed or denied depending on the user's name or role.

class CommentController extends CController {
    public function filters()
    {
        return array( 'accessControl' ); // perform access control for CRUD operations
    }

11 0
12 followers
Viewed: 105 370 times
Version: 1.1
Category: How-tos

Actions code reuse with CAction

Created 13 years ago by Antonio Ramirez, updated 13 years ago by Antonio Ramirez.

Gii provides us normally with the following code on the 'actionCreate':

public function actionCreate()
{
   $model=new ModelName;

33 0
19 followers
Viewed: 54 771 times
Version: 1.1
Category: How-tos

How-To: Create a REST API

Created 13 years ago by jwerner, updated 9 years ago by Rohit Suthar.

This article will explain how to create a REST API with the Yii framework.

98 2
123 followers
Viewed: 498 336 times
Version: 1.1
Category: How-tos

Uploading multiple images with CMultiFileUpload

Created 13 years ago by rsingh, updated 13 years ago by Maurizio Domba Cerin.
33 0
38 followers
Viewed: 129 801 times
Version: 1.1
Category: How-tos

Prevent asset publishing for CListView

Created 13 years ago by Mike, updated 13 years ago by Mike.

If you don't want to use any of the AJAX features of CListView and thus want to prevent that it publishes any of its asset files, you can extend it and create a sub class like this:

2 0
6 followers
Viewed: 14 178 times
Version: 1.1
Category: How-tos

How to avoid multiple Ajax Request

Created 13 years ago by nickcv, updated 13 years ago by nickcv.

CHtml::ajaxLink(), CHtml::ajaxSubmitButton() and similar methods are great, but if they are located inside a portion of the page that is already loaded via ajax something bad will happen, something you may even not notice if you are not using tools like firebugs...

17 0
27 followers
Viewed: 66 228 times
Version: 1.1
Category: How-tos

Using International Dates

Created 12 years ago by Russell England, updated 11 years ago by nkd.

So here is my complete solution - note that I'm using the 'short' date format throughout.

15 0
24 followers
Viewed: 49 183 times
Version: 1.1
Category: How-tos

How to generate Yii-like Documentation

Created 12 years ago by Asgaroth, updated 11 years ago by fsb.

Something a good application cant miss is documentation, and what would be better than some nice formatted HTML documentation that can be auto-generated from your code, we know several tools that already do this like phpDocumentor, but today we are introducing Yii Docs Generator...

41 0
42 followers
Viewed: 47 862 times
Version: 1.1
Category: How-tos
Tags: doc

How to write a simple application component

Created 12 years ago by zaccaria, updated 12 years ago by zaccaria.

An application component is a confortable way for share information among all component of the application

15 7
14 followers
Viewed: 74 711 times
Version: 1.1
Category: How-tos

Converting an Artisteer Theme to Yii

Created 12 years ago by bglee, updated 12 years ago by bglee.

There are two approaches to converting an Artisteer theme. The first is to simply copy an existing Artisteer – based Yii theme, overlay the CSS and images, then make any necessary tweaks to the layout files. This is undoubtedly the fastest route, but won't teach you as much as doing it from scratch. That's ok. Sometimes getting the job done is the top priority. The second approach is more gen...

6 0
12 followers
Viewed: 30 304 times
Version: 1.1
Category: How-tos

Using Pear Mail Mail_Mime and Mail_Queue

Created 12 years ago by Loren, updated 12 years ago by Loren.

require_once 'Mail.php'; // PEAR Mail require_once 'Mail/mime.php'; // PEAR Mail_mime require_once 'Mail/Queue.php'; // PEAR Mail_queue require_once 'Mail/Queue/Container/mdb2.php'; // PEAR Mail_queue mdb2

7 0
11 followers
Viewed: 15 799 times
Version: 1.1
Category: How-tos

Local time zones and locales

Created 12 years ago by Russell England, updated 12 years ago by Russell England.

The sql 'set time_zone' ensures that all dates retrieved are in UTC time. If your MySql server has the time zone names installed then use 'UTC' instead of '+00:00'.

Components

Copy the code at the end of this wiki for LocalTime.php and DefaultDateTimeParser.php int...

13 2
23 followers
Viewed: 99 735 times
Version: 1.1
Category: How-tos

Single table inheritance

Created 12 years ago by samdark, updated 12 years ago by samdark.

Relational databases do not support inheritance so if we need to represent it, we have to somehow store meta info while keeping performance by minimizing JOINs. One way to solve this problem is using single table inheritance. All fields for the whole class tree are stored in a single table. Class name is stored in the type field...

34 0
35 followers
Viewed: 52 923 times
Version: 1.1
Category: How-tos

Sub-domains with different databases in Yii!

Created 12 years ago by jwerd, updated 12 years ago by jwerd.

I used another example posted here a while back where the person was modifying the index.php and adding in a switch case for different domains and loading separate config files. This was actually too much for me, because all my portals are the exact same (as far as routes, modules, extensions, etc) and if I ever wanted to add another route it wouldn't be feasible opening up all the config files t...

2 0
12 followers
Viewed: 25 737 times
Version: 1.1
Category: How-tos

How to use EzComponents in Yii

Created 12 years ago by Ehsanjs, updated 12 years ago by samdark.

change your index.php

4 0
6 followers
Viewed: 13 305 times
Version: 1.1
Category: How-tos

How to create a wrapper for a js library

Created 12 years ago by zaccaria, updated 12 years ago by Maurizio Domba Cerin.

This wiki will explain how to include a javascript library in a widget.

16 1
20 followers
Viewed: 22 803 times
Version: 1.1
Category: How-tos

How to show ajax delete status in CGridView like flash messages

Created 12 years ago by hasanavi, updated 11 years ago by adlersd.

I've seen many tickets regarding how to show friendly delete confirmation using CGridView's CButtonColumn in ajax request. If you are using relational database, after producing CRUD functionality when you try to delete a record in ajax mode which has child record it can't be deleted and you can see the ajax loader forever. By this way you can't show the users if a record has been successfully dele...

17 0
30 followers
Viewed: 56 076 times
Version: 1.1
Category: How-tos

How to use an application behavior to maintain runtime configuration

Created 12 years ago by zaccaria, updated 11 years ago by Pablovp.

In this tutorial will be explained a method to manage some configuration runtime. This excellent tutorial follows a similar approach, but requires to write a masterclass which all controllers are supposed to extend, following this wiki you can achieve the same by only editing the configuration.

26 0
25 followers
Viewed: 42 368 times
Version: 1.1
Category: How-tos

Creating a CSS Driven Drop Down Menu using CMenu

Created 12 years ago by blindMoe, updated 12 years ago by blindMoe.

[CMenu] offers great functionality and the ability to customize just about every aspect of the output. There are many times when I need to create a drop down menu or simply modify the look to make the designers happy. Because this seems to be a common task for me, I figured I would share my code to create a very simple drop down menu that other people could use.

19 1
25 followers
Viewed: 98 644 times
Version: 1.1
Category: How-tos

ISA hierarchy of tables inside a database and how to implement a single form

Created 12 years ago by pligor, updated 12 years ago by pligor.

Please consider the following Dear software engineers imagine I have a simple ISA hierarchy: parent A with children B and C. So let's say we have the corresponding tables named "a", "b", "c" and (created with the help of the gii model creator) the classes A, B, C The following is a screenshot from MySQL workbench: ![MySQL workbench screenshot](http://s4.postimage.org/4tuwkm43d/Screenshot.pn...

1 0
3 followers
Viewed: 16 723 times
Version: 1.1
Category: How-tos