I'm trying to use Phil Sturgeon's CodeIgniter Template library, but I can't get it to change my pages. I read the documentation, followed the steps there,
Download
Copy to application folder
Create a views/layouts/default view
(Auto)load the library
however, it is not clear as to how the template is actually implemented. I thought that loading the view would apply the template everywhere, but it doesn't seem to work that way. I've also read about it in the CodeIgniter Wiki, but it looked too complicated to be the right answer.
How are you supposed to use Phil Sturgeon's Template with your controllers? (or views?) Am I missing something here?
It does not overload the load->view() methods, that would be bad. You need to update your controllers to use the template's syntax and methods in every instance you want to use it:
http://philsturgeon.co.uk/demos/codeigniter-template/user_guide/
You will use $this->template->build() instead of $this->load->view() in most cases, after constructing your template by defining regions, setting titles, etc.
There should have been a user guide included in your download with examples.
Related
I just want to create custom html with good css form with my own php as backhand code and javascript for validation.. Is there any extension for this?
I have seen few extensions but none of them allows me to add my own php backhand code.
Thanks
If you are not going to use Joomla's framework, then you may as well build the form outside of joomla and insert it into the article via an iframe (you may need to change the editor's permissions to allow you to do this).
It is worth looking into using the framework properly, however, as it does have easy-to-use mail classes and actually makes things easier when you get your head around it.
(Though to answer your actual question - this module appears to allow you to add raw php http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules/3668 )
I believe Smarty templates has functionality built in that allows you to manage your site URLs from a config file so if something gets moved, you only have to update the URL in one place. Does this sort of functionality exist in CodeIgniter? If not, any pointers or examples on how/where to add it?
For example:
Instead of hard-coding the link it would be: Settings
But where would you want to set $links so that it was available everywhere? Or is it really best to just hard code them?
Take a look at the config class. It allows you to make custom config files.
It's not entirely made for URL's but you sure can use them.
The base url should be basically right at the start of /app/config/config.php, where app is the name of your codeigniter application folder. You access it through calls to the base_url() function.
Yes, it's called Routes, configuration located at config/routes.php. Documentation
If you ask about the rendered html of the links, then your best bet would be using site_url() in conjunction with constants, for example site_url(URL_SETTINGS);, there is no built in functionality for that, but I can say I don't think that is necessary as it would be used too rarely, but it would influence performance every single load.
I would like to create for my Yii application, a site where I can describe each model, view and controller used. However, doing this for each and everyone of my classes would be an extremely long task which I believe might already be solved out there.
Is there a way to automatically create an site with each model/view/controller and its methods, so then I can add a description to it?
Have you tried phpDocumentor http://www.phpdoc.org/? It's crawls your PHP files' comments and generates a simple website for them in the spirit of JavaDocs.
Or, better still, there is a custom extension you can use to build docs like those on the Yii site call Yii Docs Generator http://www.yiiframework.com/extension/yiidocsgenerator. See the details at http://www.yiiframework.com/wiki/186/how-to-generate-yii-like-documentation
I would take a look at T4MVC - it uses a T4 template to generate code for each controller / method. Maybe you could utilize it.
Have you looked into the Gii module of yii. Once you create the tables it can produce models and then CRUD (create, update, delete) pages. Excluding the database there would be no programming required. And then you have the full source in a readable and documented form to manipulate and change to suite your needs.
If you wan't something a bit more advanced or custom you could extend Gii and produce some of your own templates
Larry Ullman has a really nice series on Learning the Yii Framework. In part 3 of the series, he walks you through configuring Yii and enabling Gii, a web-based automated code generation tool for Yii. In part 5, he shows you how to use it to generate the code for your models. The whole series is a really nice introduction to Yii, I recommend it.
I am about to implement localization for my MVC3 web application. Googling my way through large amounts of ways to do it, I was left unsure which way to implement this. I found few ways how to do it:
First option I found was to use App_GlobalResources and ViewData and culture select with Map Routing. (Link)
Second was to make a separate Resources folder in my project and structure it like Model and View folders. Then create the resource files in those folders. To use those resource strings would be like using the Viewbag. Then edit the Global.asax to handle culture changing and create a partial view to allow changing cultures. The instructions to do this are very thorough so this might be the best bet.
(Link)
Third was to use DisplayAttribute and resx-files. This one was a bit hazy, I could not find the sort of information so that I could grasp how this actually is implemented and its restrictions. (Link)
Fourth was to create a custom class to handle resources. This seemed pretty fancy and easy to implement and use but no real information was found if it actually worked. (Link)
Then I found a post that warned about using the App_GlobalResouces and App_LocalResources. (Link)
After going through possible ways of doing localization. I could not find a way which was universally approved or accepted. This left me pondering, which of these, or some I didn't find, would be the best way to implement localization in ASP.NET MVC3?
Then I found a post that warned about
using the App_GlobalResouces and
App_LocalResources. (Link)
I found that post extremely useful. The method explained there is very clean. Here is a snippet of my newly created index view using that method:
#using Resources.Index
#{
ViewBag.Title = "Index";
}
<h1>#Index.Title</h1>
I don't think there is a definitive do-it-this-way-or-else method, so going for the cleanest method seems to me like a good deal.
I've come up with an easier way to handle localization where you don't have to use resource files or attributes. It involves custom metadata providers.
MVC3 uses metadata providers to get all text strings. My approach allows you to either use string tables, a database, flat files or any other source to provide the translations. All you need to do is to inherit two interfaces.
Read about it here: http://blog.gauffin.org/2011/09/easy-model-and-validation-localization-in-asp-net-mvc3/
Edit
Everything is now documented at github and there are nuget packages: https://github.com/jgauffin/griffin.mvccontrib
I don't want to remove smarty templates from controllers. In some actions of controllers, I want to use default view system of codeigniter, while on other actions, I want to keep SMARTY templates as display medium. How can I achieve this?
Thanks in advance
I've been developing a CI Smarty library for Codeigniter. It lets you use default Codeigniter views and lets you render Smarty templates using the Codeigniter template parser as I am extending it.
Here is the repository: https://github.com/Vheissu/Ci-Smarty
As it stands, it works really well. If you have any problems, log an issue on Github and I'll fix it usually within 24 hours. Other solutions are mostly outdated, my library lets you use new Smarty 3 features like template inheritance, etc.
Look in the CodeIgniter Wiki - http://codeigniter.com/wiki/Smarty/
And a thread in the official forum:
http://ellislab.com/forums/viewthread/60050/