Joomla output override not working - php

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

Related

The technical reason is: No template was found. View could not be resolved for action "search" in class "LoginController"

Im new to typo3 and ive been trying to develop an extension for it. When I load the plugin to the page i get and error:
Sorry, the requested view was not found.
The technical reason is: No template was found. View could not be resolved for action "search" in class "LoginController".
In the login controller i have a function searchAction and I do have a template inside
\Resources\Private\Templates\StoreInventory\Search.html
What might be the error? I followed the documentation for extension development by typo3. I even downloaded the code from GIT and tried using that but no luck.
TL;DR: It should be placed at Resources/Private/Templates/Login/Search.html
explanation:
From your question I can tell you've used the documentation on https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/4-FirstExtension/6-adding-the-template.html
It is not wrong, but you've missed a vital step. When you take a look at the path they are using you'll see that a lot is done automagically. Let's break it down.
They have a controller with an action and a template related to it in the following path
controller:
\MyVendor\StoreInventory\Controller\StoreInventoryController
action: listAction
template: EXT:store_inventory/Resources/Private/Templates/StoreInventory/List.html
If you look closely you'll see that the template path is made up from several components.
the extension (EXT:store_inventory)
the default template directory path (Resources/Private/Templates)
The Controller name without the controller suffix (StoreInventory)
the Action name without the action suffix (List)
the .html suffix
If you take that information and apply it to your case it would be:
the extension (EXT:your_extension_name)
the default template directory path (Resources/Private/Templates)
The Controller name without the controller suffix (Login)
the Action name without the action suffix (Search)
the .html suffix
So the end result would be something like
EXT:your_extension_name/Resources/Private/Templates/Login/Search.html
It is true that you can use typoscript to change this behaviour or set overrides or extended templating for instance. But I think you're working from the default, and this should be the working path for you now
First check your templateRootPaths in Configuration/TypoScript/setup.typoscript
And set accordingly.
Try placing the file at \Resources\Private\Templates\Search.html as \Resources\Private\Templates is the default path unless you have altered it.

using layout in themes from inside module Yii PHP

In Yii application I used own theme(demirTheme) have modules(retail, corporate), and layouts(main, layout_retail, layout_corporate).
When rendering one page(ex index) I want my app to render page, related layout (retail vs corporate) and then main accordingly. How can I achieve this?
I read layout tutorials and questions no help. They only mention about changing layout path, setting default layout for module, and so on.
I tried
to put all layouts in themes layouts folder,
to put main layout in themes layouts folder and other two in modules layouts folder respectively by their module,
to put all layouts in protected/view/layouts folder,
to put all layouts in modules and one copy of main layout for each module
But can't get it work. I tried changing layout path and other settings.
Is there any way? Have you done layout rendering like this? Any suggestions welcome.
add public $layout='//layouts/layout_retail'; in the controller you want to apply the layout to (so in every controller in the retail module for example). The views should be in "protected/view/layouts"
http://www.yiiframework.com/doc/api/1.1/CController#layout-detail
I am also sure you can put the layouts in the modules map. I however use the above methode for our admin module.
http://www.yiiframework.com/doc/api/1.1/CWebModule#layout-detail
EDIT:
You retail or corporate layout should be then like the code underneath. So the retail or corporate layout would be inside the main layout. Clearly it should contain more then just this, but the content of you layouts should be within $this->beginContent('//layouts/main'); and $this->endContent();
<?php $this->beginContent('//layouts/main'); ?> //main
<div id="content">
<?php echo $content; ?> //viewOfRetail
</div>
<?php $this->endContent(); ?>
For the newcomers: in many help forums of the Internet, when someone asks about theming a module, everyone suggests a path alias to the themes folder, and I disagree with those other forums. I think this is wrong, because it implies modules to be splitted, and modules are supposed to be a black-box that can be used across projects. The advice given in such forums would only be valid if a theme is shared among several modules. If someone wants to "package" a theme inside a module, she can:
-add an init function to the controller of the module
-inside that init, use the class attribute layout and a path alias, like this, supose a module whose id is "Sample":
then you add, to SampleController.php:
public function init() {
//BELOW: it will use the layouts/main.php inside the module.
$this->layouts = "sample.views.layouts.main";
}
Yo can check about path alias here:
http://www.yiiframework.com/doc/guide/1.1/en/basics.namespace

Running two versions of a site from same Yii code

I have two versions of my project. For one i use a different CSS and index page and for another i use different. Rest of the things that is controller, models and components are same. The only difference is in view(one or two files) and CSS.
Is there any way to manage this? Like when the URL is URL1 then use CSS1/View1 folder and when url is URL# use CSS2/view2 folder. I have gone through the modules section of Yii but i don't think they are what i need here.
So now I started to use themes. My folder structure is like:
WebRoot
- assests
- css
- images
- protected
- themes
- theme1
-views
-site
-layout
-template
- theme1
-theme2
-views
-site
-layout
-template
In my controller I have done this:
public function init() {
if (SITE_TITLE == 'xxxxx')
Yii::app()->theme = 'theme1';
else
Yii::app()->theme = 'theme2';
parent::init();
}
Which sets theme correctly. but i keep getting file not found as renderer is looking in protected.
I think, you need use themes. Here is documentation: http://www.yiiframework.com/doc/guide/1.1/en/topics.theming
UPDATED after discussion
Trouble in ETwigViewRenderer and it working with themes
If you want to change entire layout, perhaps this is a good way to do:
Setting Layout in Yii
In case you want only to change css they why don't you rely on request uri or domain name?
Yii::app()->getBaseUrl(true)

How to load view from alternative directory in Laravel 4

In my Laravel 4 application's root directory, I have a folder themes. Inside the themes folder, I have default and azure.
How can I access view from this themes/default folder in a specific route.
Route::get('{slug}', function($slug) {
// make view from themes/default here
});
My directory structure:
-app
--themes
---default
---azure
I need to load views from localhost/laravel/app/themes/default folder. Please explain this.
This is entirely possible with Laravel 4. What you're after is actually the view environment.
You can register namespace hints or just extra locations that the finder will cascade too. Take a look here
You'd add a location like so:
View::addLocation('/path/to/your/views');
It might be easier if you namespace them though, just in case you have conflicting file names as your path is appended to the array so it will only cascade so far until it finds an appropriate match. Namespaced views are loaded with the double colon syntax.
View::addNamespace('theme', '/path/to/themes/views');
return View::make('theme::view.name');
You can also give addNamespace an array of view paths instead of a single path.
Here I am not accessing my project from public folder. Instead of this I am accessing from project root itself.
I have seen a forum discussion about Using alternative path for views here. But I am little confused about this.The discussed solution was,
You'd add a location like,
View::addLocation('/path/to/your/views');
Then add namespace for theme,
View::addNamespace('theme', '/path/to/themes/views');
Then render it,
return View::make('theme::view.name');
What will be the value for /path/to/ ?
Can I use the same project in different operating system without changing the path?
Yes, we can do this using the following,
Put the following in app/start/global.php
View::addLocation(app('path').'/themes/default');
View::addNamespace('theme', app('path').'/themes/default');
Then call view like the default way,
return View::make('page');
This will render page.php or page.blade.php file from project_directory/app/themes/defualt folder.
I've developed a theme package for laravel 5 with features like:
Views & Asset seperation in theme folders
Theme inheritence: Extend any theme and create Theme hierarcies
Try it here: igaster/laravel-theme
\View::addLocation($directory); works fine but the new right way to do it is using loadViewsFrom($path, $namespace) (available on any service provider).

Symfony subdirectory lib/form/<new_directory>

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;

Categories