EzDev.org

yii

Yii PHP Framework 1.1.x Yii PHP Framework: Best for Web 2.0 Development yii is a high-performance component-based php framework best for web 2.0 development.


Basic Hidden field in yii

I'm trying to place data in hidden text in yii, but I don't know how. I need a similar code to a regular php syntax:

<input type="hidden" name="field_name" value="a"/>

It's supposed to be a field with static value of a. I just need it to go with my $_POST variables for error checking.

Is it possible to avoid modifying the models and controllers just to put the field in?I cant use gii cause I only have snippets of code with me.Sorry as well as I have little understanding of yii so I have no clue if what I'm saying about the last 2 sentences is correct.


Source: (StackOverflow)

Yii: Multi-language website - best practices

I find Yii great framework, and the example website created with yiic shell is a good point to start... however it doesn't cover the topic of multi-language websites, unfortunately. The docs covers the topic of translating short messages, but not keeping the multi-lingual content ...

I'm about to start working on a website which needs to be in at least two languages, and I'm wondering what is the best way to keep content for that ... The problem is that the content is mixed extensively with common elements (like embedded video files).

I need to avoid duplicating those commons ... so far I used to have an array of arrays containing texts (usually no more than 1-2 short paragraphs), then the view file was just rendering the text from an array.

Now I'd like to avoid keeping it in arrays (which requires some attention when putting double quotations " " and is inconvenient in general...).

So, what is the best way to keep those short paragraphs? Should I keep them in DB like (id | msg_id | language | content ) and then select them by msg_id & language? That still requires me to create some msg_id's and embed them into view file ...

Is there any recommended paradigm for which Yii has some solutions?

Thanks, m.


Source: (StackOverflow)

Emberjs, server side vs client side, All in?

I have been looking into Ember.js, and it looks really great, but one thing that concerns me, and that I can't get my mind around it, is if I start using it on an already running project.

Will I eventually have to move everything client side, and make my application a single page application at some point?

let me clarify...

So far the best way to communicate between client and server using Ember is REST. and that looks great, but what I don't like is having all the templates loaded for the first time. and moving all the logic in my server to the client (or am I getting all of this wrong?), cause it looks like my server side will become a logic-less REST API.

Also, I'm using Yii Framework which has some JavaScript (Ajax enabled) components like grids. how can I have ember interact with all of this on navigation without having to rewrite a bunch of stuff already working on my application?

I'm on the login page (or state), and then after login in, I have to display a grid, that is just easy with Yii, and a full page load, but If I am using Ember, how can I have my grid display as it normally would? do I have to pre-load a handlebar template for the grid, and also the JavaScript that controls it?


Source: (StackOverflow)

Yii framework: Controller/Action url & parameters

In my application , I have ApiController with actionUsers, So in YII the path becomes api/users. Now in order to get certain users info , I use the following path api/users/id/10 where 10 is the userID and id part of the path is basically a GET parameter (api/users?id=10).

Is there any way to do the same thing without id part of the path, i.e. I want my path to look like api/users/10?

Thank you!


Source: (StackOverflow)

What is the difference between homeUrl and baseUrl in Yii frame work?

What is the difference between homeUrl and baseUrl in Yii frame work ?


Source: (StackOverflow)

Yii: Render action using different layout than controller's layout

In Yii, is there a way to render a single action using a different layout than that defined for the controller? I have an action that I would like to format differently from the rest, and it's not clear from the documentation if that's possible.


Source: (StackOverflow)

Cakephp and Yii: similarities/differences/speed?

I am a CakePhp programmer. I have decided to try out the Yii framework. I would like to find out in what ways is CakePhp is similar to and different from Yii. Also, is Yii measurably faster than CakePhp as they claim?


Source: (StackOverflow)

yii: how to make a unique rule for two attributes

I have a table like this: (id, name, version, text). (name, version) is unique key, how can i make a rule to validate this.


Source: (StackOverflow)

how to pass parameter on redirect in yii

I am using Yii framework for my project;

I am redirecting page after success of insertion in database to another controller using

$this->redirect($this->createUrl('controller/action'));

During the redirection is it possible to pass any parameters just like in render,

$this->render('selectRefiner', array('param' => $data)


Source: (StackOverflow)

A CMS based on Yii? [closed]

i've been with Yii for a few months and before I use main CodeIgniter, SilverStripe in my projects. Does anyone know a good Yii based CMS such as SilverStripe based on Sapphire or EE based on CodeIgniter ?

My experience is working with Yii is much more easier and straightforward assuming you are good OOP coder but Yii is still young and there are not lot of samples that I can put together quickly for a real prodcution project.

A couple of YII based CMS I spotted at do not look really promising or maybe at a very early stage such as dotPlant, Web3CMS.


Source: (StackOverflow)

Where to learn Yii? [closed]

I have been trying to learn Yii without luck. I find Zend Framework, Kohana, Code Igniter among other frameworks much easier to learn than Yii. The documentation also su**s. Can you post links to easy-to-understand and well written tutorials/articles? The official documentation is filled with grammar errors and seems to be rushed...


Source: (StackOverflow)

How to get response as json format(application/json) in yii?

How to get response as json format(application/json) in yii?


Source: (StackOverflow)

Yii2: Why is the auth key in class User?

As the title clarifies why is the auth key introduced in Yii2? What're it's main usages and how it is useful in authentication?


Source: (StackOverflow)

Yii2 how does search() in SearchModel work?

Please can someone explain how the search method in a Yii2 SearchModel works? I generated it using Gii. Here it is:

public function search($params){
    $query = MyModel::find();
    $dataProvider = new ActiveDataProvider([
        'query' => $query,
    ]);

    if (!($this->load($params) && $this->validate())) {
        return $dataProvider;
    }

    $this->addCondition($query, 'att1');
    $this->addCondition($query, 'att1', true);
    $this->addCondition($query, 'att2');
    $this->addCondition($query, 'att2', true);

    return $dataProvider;
}

This is how I call it:

$search = new MyModelSearch();
$myModels = $search->search(['att3' => '3']);

Regardless of what attributes I use in calling search, I always get back the same result - i.e. all the entries in the table. I'm missing something here that I just do not understand.

Any help would be really appreciated. Thanks.


Source: (StackOverflow)

Get current controller and action id in Yii

I want to force all users to log in before accessing pages of my site. I have followed Larry Ullman's tutorial Forcing Login for All Pages in Yii.

According to the tutorial you can make an exception for some pages to avoid redirecting to the log in page. In order to check the current controller it has checked $_GET value. My problem is that I have used urlManager to rewrite the URL and $_GET gives me a null value. Is there any method I can use to get the current controller and action in the score of my class?

I tried the following but it is not accessible in the scope of my component class:

Yii::app()->controller->getId

Source: (StackOverflow)