Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,177 members, 7,815,129 topics. Date: Thursday, 02 May 2024 at 07:52 AM

A Question For Yii2 Users - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / A Question For Yii2 Users (1827 Views)

Software developers. A question regarding work-life balance. / Yii2 Development Visualization / Yii2 Rest API Question (2) (3) (4)

(1) (Reply) (Go Down)

A Question For Yii2 Users by CRAZYMADMAN(m): 1:32pm On Aug 07, 2015
If you decide to use the yii2 active form widget in your main layout page ( usually main.php) for some reasons, for example building a "subscribe to our newsletter " form that shows on all your pages, how do you handle the controller call? Which controller gets called
Re: A Question For Yii2 Users by babatope88(m): 5:53pm On Aug 07, 2015
Make I wait here for pcguru, e be Oga at the top for yii2,
Re: A Question For Yii2 Users by Nobody: 8:19am On Aug 08, 2015
CRAZYMADMAN:
If you decide to use the yii2 active form widget in your main layout page ( usually main.php) for some reasons, for example building a "subscribe to our newsletter " form that shows on all your pages, how do you handle the controller call? Which controller gets called

Don't put it in the main layout rather have it as a Widget and I will explain the reasons:

1. Putting it in the main layout would mean everything you have to create a Model in each controller to send to that form which means repetition of code.
2. Non flexibility , the more controllers you create the more code to add for the widget

Now you might be thinking to yourself why not put the code in the main Controller class that all the controller extend, but you see in Yii2 it's built to make things more modular

So my approach is to create it as a Widget, because with widget all the logic and views will be contained inside that Widget all you just need to do is copy that Widget to another Project and there will be little change of code.

e.g

a Widget class has 2 important calls init and run,

use the init to check for POST Data and give your a specific name so that you don't end up assigning another form to it, then in the run method depending on your logic you can render whatever view you want to send e.g Success Registration signup or error.
Re: A Question For Yii2 Users by Nobody: 8:55am On Aug 08, 2015
Glad to see another Yii2 Dev wink do you know any Yii2 CMS thinking of building one from scratch like OctoberCMS, but coupled with my daily job it's hard i tried to collaborate with an international CMS but it's in Yii1 and he too is too busy cry
Re: A Question For Yii2 Users by CRAZYMADMAN(m): 11:31am On Aug 08, 2015
pcguru1:


Don't put it in the main layout rather have it as a Widget and I will explain the reasons:

1. Putting it in the main layout would mean everything you have to create a Model in each controller to send to that form which means repetition of code.
2. Non flexibility , the more controllers you create the more code to add for the widget

Now you might be thinking to yourself why not put the code in the main Controller class that all the controller extend, but you see in Yii2 it's built to make things more modular

So my approach is to create it as a Widget, because with widget all the logic and views will be contained inside that Widget all you just need to do is copy that Widget to another Project and there will be little change of code.

e.g

a Widget class has 2 important calls init and run,

use the init to check for POST Data and give your a specific name so that you don't end up assigning another form to it, then in the run method depending on your logic you can render whatever view you want to send e.g Success Registration signup or error.


A widget of course! Why didn't I think of it.

Thanks man
Re: A Question For Yii2 Users by CRAZYMADMAN(m): 11:55am On Aug 08, 2015
pcguru1:
Glad to see another Yii2 Dev wink do you know any Yii2 CMS thinking of building one from scratch like OctoberCMS, but coupled with my daily job it's hard i tried to collaborate with an international CMS but it's in Yii1 and he too is too busy cry

If you can modify easyii cms it would be great. The overall design is good but it has many broken links when I tried to run it from my localhost. You can also check out dotplant cms ( the primary Language is not English)
Re: A Question For Yii2 Users by Nobody: 1:49pm On Aug 08, 2015
CRAZYMADMAN:


If you can modify easyii cms it would be great. The overall design is good but it has many broken links when I tried to run it from my localhost. You can also check out dotplant cms ( the primary Language is not English)

Russian CMS is for e-commerce I think and also Easyii CMS isn't written well my plan is to build a CMF that glues Yii2 Modules together and play with Yii2 convention so am only creating a Yii2 app to aid Developers create applications something like SiteInfinity or maybe am too ambitious. I will create a document one of these days explaining or jotting stuff down.but try writedowncms it's the Yii2 replica of WordPress
Re: A Question For Yii2 Users by CRAZYMADMAN(m): 6:26pm On Aug 08, 2015
pcguru1:


Russian CMS is for e-commerce I think and also Easyii CMS isn't written well my plan is to build a CMF that glues Yii2 Modules together and play with Yii2 convention so am only creating a Yii2 app to aid Developers create applications something like SiteInfinity or maybe am too ambitious. I will create a document one of these days explaining or jotting stuff down.but try writedowncms it's the Yii2 replica of WordPress


That would require extensive knowledge of Yii2 and am not yet very comfortable with stuffs like the dependency injections and a few other aspects of yii2. But I seriously hope you finish the project, might even be one of the first persons to use it cheesy
Re: A Question For Yii2 Users by Nobody: 7:28pm On Aug 08, 2015
CRAZYMADMAN:



That would require extensive knowledge of Yii2 and am not yet very comfortable with stuffs like the dependency injections and a few other aspects of yii2. But I seriously hope you finish the project, might even be one of the first persons to use it cheesy

I hope so too I hope so
Re: A Question For Yii2 Users by Nobody: 11:58pm On Oct 03, 2015
Sorry just wanted to update this thread, I decided to go with Yii2-starter-kit it has everything i need without me killing myself so am just adding my modules to it and it works well for our projects. you should give it a try and the advanced template is worth it, though i removed most of the config not applicable to me.
Re: A Question For Yii2 Users by CRAZYMADMAN(m): 9:12pm On Oct 05, 2015
Bro, can you upload it somewhere for me to download. (without your own programming logic, of course) but the composer.json should be intact so I get the full package.
Re: A Question For Yii2 Users by Nobody: 3:54pm On Oct 06, 2015
CRAZYMADMAN:
Bro, can you upload it somewhere for me to download. (without your own programming logic, of course) but the composer.json should be intact so I get the full package.

The best way is using composer else it's gonna be hell doing it yourself.

composer create-project --prefer-dist --stability=dev trntv/yii2-starter-kit

(1) (Reply)

The 9 Most Demanded Programming Languages Of 2016 / Game Character Artist Available. I Am Here / Best Programming Books 2020.

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 26
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.