I am going to program a website in symfony 1.4. It is working very fine. But I have on question.
How can access to a subfolder in lib/forms/
Example:
I have an accountForm.php in
/lib/forms/account/accountForm.php
How can I get to this in the template and in action, when my module is called "account".
I can include the accountForm.php pretty good, when I am putting it in
/lib/forms/accountForms.php
But I want it the other way to have more overview. Can somebody help me?
Well part of the issues is probably that you havent named the file properly... it should be AccountForm.class.php if it is an actual form class. As long as it is named that way it should autoload just fine. Just make sure you clear cache after you have added a new file.
If its not a class then it doesnt belong in a lib directory. That exactly is in accountForm.php?
You might also want to customize you autoloading configuration if you are sure of what youre doing: http://www.symfony-project.org/reference/1_4/en/14-Other-Configuration-Files
I'm not sure but try adding the form's path to autoload.yml
yourProject/config/autoload.yml
use %SF_MODEL_LIB_DIR%/forms if the form is in lib/model/forms
or %SF_LIB_DIR%/forms if the form is in lib/forms
autoload:
customForm:
name: yourForm
path: %SF_MODEL_LIB_DIR%/forms/accounts/
recursive: on
Name the account form accountForm.class.php and then in your action you can just do:
$this->form = new accountForm();
and in your template:
echo $form;
Related
I would like to add a new phtml file to my index folder in which I already have several views:
index
landing
And so on... I access them by using the following logic:
sitename.com/index/landing
or
sitename.com/index/index
How can I add the phtml file (my new view) to my index folder so that I'm able to see it when I enter in the browser:
sitename.com/index/mynewview
I'm quite new to the whole Zend Framework, and I'm not sure how the structure works exactly, so I'd like to find out more. Can you guys help me out with this, how am I supposed to do this?
Thanks heaps! :)
P.S. The views are in the following directory structure:
module/application/view/application/index/
and then here are all of the views, this is where I'd like to add my new view and access it from browser like this:
/index/testview
Edit:
When I add the testview.phtml to the index directory and put some test tags like this in it:
<h1> Testing new view page </h1>
It's not being rendered on the browser
Because this is an MVC framework, you're skipping a few steps. You're probably going to get a few harsh responses, but I'll try to fill in the holes for you very quickly.
Ignore the file folder structure for a minute.
This is a route:
/index/landing
Routes point to Actions inside of Controllers to work.
Assuming you have started with the skeleton, open up your module's module.config.php, you should see route config, e.g.:
https://github.com/zendframework/ZendSkeletonApplication/blob/master/module/Application/config/module.config.php#L29
You'll need to add a config entry for the routes you want to serve. It could be as simple as a Literal entry for /index/landing, or something more complex (Segments, Regex, etc.) that handle patterns for routing. Spend some time tinkering and learning here; routes are pretty critical to working with MVC.
When configuring the route, the assumption is that you have a Controller set up, and that this Controller has an Action (to which your route is pointed). That Action, is where you can connect template files (phtml,twig,etc.) to routes:
// dummy action that serves index/testview
public function fooAction(){
$vm = new Zend\View\Model\ViewModel();
$vm->setTemplate('index/testview');
return $vm;
}
That index/testview, will be in your module's view templates, not in your public folder.
I think that's a reasonable primer to get you on your way!
Take some time to learn:
http://zf2.readthedocs.io/en/latest/index.html#userguide
Maybe start here:
http://zf2.readthedocs.io/en/latest/in-depth-guide/understanding-routing.html
ZF2 (V3 is coming!) is a beautiful thing, it's worth it.
Good luck.
I have some code, where is used Form helper. All worked well. Now I have error
Call to undefined method Form::open()
When I check SYSPATH exist classes Form and Kohana_Form
This situation is in each file where is used this helper.
This is kohana 3.2. In this files was not any changes. I tried it on PHP 5.4 and PHP 5.5
Any idea why? Thanks in advance for help.
The most likely thing is that you have a Form.php somewhere that's overriding the SYSTEM Form.php. To find out if this is happening, use the Kohana::find_file() function like this:
Kohana::find_file('classes', 'form');
The output from this should tell you the path of the Form.php that's being used when you call the Form class. Check if it's the one in the SYSTEM folder.
I am using SS 3.02 and have made a lots of modification in the core files. I am facing the issue that I am trying to set the color of the navigation background dynamically. This works fine for pages other than security/login page. Suppose I am getting the value in $navbgcolor, this shows up well on home page or about us page or any other page. But this does not show up on the Security/login page. Any help would be greatly appreciated. Thanks.
Firstly, it is never a good idea to alter the core files as this prevents you from easily updating your version of SilverStripe. You could miss out on bug fixes and important security updates.
The reason this isn't working on the login page is because the login page works from the Security controller which directly extends Controller. Your code (presumably in Page_Controller) will be completely bypassed.
Here is a way you could apply your code to all controllers, without touching the core:
<?php
class MyControllerExtension extends Extension {
public function onAfterInit() {
//... Your code here...
}
}
In your config file you would apply your new controller extension to Controller.
If you're using _config.php
Object::add_extension("MyControllerExtension", "MyControllerExtension")
If you're using YAML (recommended)
Controller:
extensions:
- 'MyControllerExtension'
You can learn more about extensions here: http://doc.silverstripe.org/framework/en/reference/dataextension
Also to let you know, you can create specific template file for the Security login pages by creating action sub-templates. Example is if you created a file in your theme called "Security_login.ss" you can call in variable, change the mark up etc.
Note the convention here is the filename is called the name of the class in this case "Security" then "_" followed by the name of the action to be rendered by your controller ("login" in this case).
As mentioned by micmania1, the golden rule for developing in SilverStripe is...
"Don't hack the core or modules!"
Instead as pointed out use extensions to decorate classes, or use subclasses if you have to.
Does anybody know why an output override won't work?
I am familiar with output override and have tried it before, but this time it wont work.
I am trying to override an article category blog layout, so I copied
\components\com_content
and paste it to my template, inside "html" folder which I just made
\templates\my_teamplate\html\com_content
I edited
\templates\my_teamplate\html\com_content\views\category\tmpl\blog.php
and it won't work, I tried editing the original core, to make sure it's the correct file
\components\com_content\views\category\tmpl\blog.php
and it worked, im pretty sure, it's the correct file, I just dont know the reason why it's not overriding.
My Joomla version is 1.5.26
The HTML override does not mirror the component's exact folder structure.
Its default structure is:
component/view/template.php
In your case:
templates/yourTemplate/html/com_content/category/blog.php
Edit
I am extending the example and adding the path for modules as well, in case anyone needs it:
Component:
The Joomla path to the original component view's template that you want to override:
/component/[componentName]/views/[viewName]/tmpl/[templateName].php
gets overridden by this file in your template:
/templates/[yourTemplate]/html/[componentName]/[viewName]/[templateName].php
Module:
The Joomla path to the original module's template that you want to override:
/module/[moduleName]/tmpl/[templateName].php
gets overridden by this file in your template:
/templates/[yourTemplate]/html/[moduleName]/[templateName].php
Folder structure should be
templates/template_name/html/com_content/category/blog.php
Let's say I have this in my bootstrap.php file in a cakePHP application:
Configure::write('Config.language', 'eng');
How can I dynamically change the value of that configuration variable based on user action in a controller of my application? I tried to do the same thing that I did above here in my controller, but that didn't work
Any help?
Try Configure::write('Config.language', 'dut'); for e.g.
This answer from the question suggested by #Ryan Pendleton shows a somewhat correct way to use this directive.
It should be used in the AppController because it gets loaded first - as the parent of all other controllers in the application itself.
I used "somewhat correct" because it is best to validate the language codes ('eng', 'fre', 'dut') in the app/config/routes.php file - go here for more information.
Also do check out this: Internationalization-Localization explanation.