Croogo : Different layout for different Locate - croogo

How to set different layout for different locate with "Translate Plugin"
ex:
with link: [http://example.com/eng] it should render default.ctp
for English
and with link: [http://example.com/ja] it should render
default.ctp for Japanese

One way you can do this is by reading the $this->request->params['locale'] variable, which is available in the Controller/AppController.php file, and then change the layout according to it. It would be something like this:
class AppController extends CroogoAppController {
public function beforeRender() {
// Some code...
// First, checks if the locale parameter is not empty
if(!empty($this->request->params['locale']))
// Then, sets the layout for each case.
// In this example, we user eng and ja
switch($this->request->params['locale']) {
case 'eng':
$this->layout = 'Croogo.eng';
break;
case 'esp':
$this->layout = 'Croogo.ja';
break;
}
// If it is empty, then loads the default locale layout
else
$this->layout = 'Croogo.default';
}
// The rest of the AppController code...
}
Note that I used the Croogo prefix for the layout files. I did this because I wanted the layout files to be loaded from within the croogo folder. In my installation, they are located in the path Vendor/croogo/croogo/Croogo/View/Layouts.
Hope it helps!

Related

Typo3 Content Elements missing in wizard

I have some content elements in a site package which I want to show up in the content element wizard as explained here:
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/ContentElements/ContentElementsWizard.html
Basically I have done the same as shown in the section "Create a new tab"
Configuration\TsConfig\Page\ContentElement\All.tsconfig is looking like this:
mod.wizards.newContentElement.wizardItems.mci.header = MCI
mod.wizards.newContentElement.wizardItems.mci {
elements {
mci_home_banner {
iconIdentifier = home-banner
title = Home-Banner
description = Banner der Startseite
tt_content_defValues.CType = mci_home_banner
}
mci_home_banner_element {
iconIdentifier = home-banner-element
title = Home Banner Element
description = Element im Starseitenbanner
tt_content_defValues.CType = mci_home_banner_element
}
}
show := addToList(mci_home_banner, mci_home_banner_element)
}
I reduced the code to just 2 elements. They are not shown at all, but are available over the dropdown, so I can switch to one of them after choosing another element.
This didn't work when created in 9.5 and still does not work after switching to version 11.5.10
What am I missing?
#user414873 Did you try to add your custom elements to the "common" tab instead of your new one "mci"?
And did you try to use an existing icon identifier (e.g. "content-image" or an other one - see https://typo3.github.io/TYPO3.Icons/)? Just to make sure that there is no problem with your custom icons that prevents the elements from being displayed.
Does this minimal example work for you:
mod.wizards.newContentElement.wizardItems.common {
elements {
mci_home_banner {
iconIdentifier = content-image
title = Home-Banner
description = Banner der Startseite
tt_content_defValues.CType = mci_home_banner
}
}
show := addToList(mci_home_banner)
}
And I would doubt this:
I guess otherwise the content elements wouldn't be available at all.
I suggest you check it's correctly included by using the "Info" module in your TYPO3 main menu. Then select the page where the content element should be included and switch the dropdown on top of the content area to "View TSconfig fields content". Now you can search for "wizards" and check if your element is included.

Fuelphp - route index with parameters

Using Fuelphp, I'd like to be able to use a URL system similar to here on StackOverflow to get to specific pages.
Desired behavior:
-stackoverflow.com/questions -> page with many questions
-stackoverflow.com/questions/1982 ->page with specific question
Here's my controller:
class Controllers_Images extends Controller_Template
{
public function action_index($id=null)
{
if($id)
{
//Use Model_Image to find specific image
//Create appropriate view
}
else
{
//Use Model_Image to find many images
//Create appropriate view
}
}
}
I can access the "generic" page with mysite.com/images/ - this is routed to the action_index function. I can access a "specific" page with mysite.com/images/index/1. What I'd like to do is be able to skip index in this case too, so that mysite.com/images/1 works. Right now I'm getting 404. How do I set up routing for this?
After poking around a bit more, I came up with a solution that works fine:
class Controllers_Images extends Controller_Template
{
public function action_index()
{
//Use Model_Image to find many images
//Create appropriate view
}
public function get_id($id)
{
//Use Model_Image to find specific image
//Create appropriate view
}
}
In routes.php:
return array(
'images/(:num)'=>'images/id/$1',
//other routing stuff...
);
With this setup, the url "mysite.com/images/1" now appropriately displays the selected image as if "mysite.com/images/id/1" was used instead. Not a huge deal, but it is a nicer interface, which is important!

Configuring Single RTE Wrapper for Multiple Classes - Typoscript/Typo3

I'm trying to write Typoscript that will configure the Typo3 Rich Text Editor to wrap a given element with more than one class.
In the project's TsConfig/Page/rte.txt file, I have:
RTE {
classes {
button {
name = Button
}
}
However, I'd like to create a wrapper that would give the element more than just a single class. The below code doesn't work, but illustrates what I'm trying to accomplish:
RTE {
classes {
button {
name = Button
}
button danger {
name = Dangerous Button
}
}
According to this article, this doesn't seem to be possible, but I thought I'd ask and see if someone out there got crafty with their Typoscript and was able to accomplish this.
I tried everything to handle styles for tables that way, but there is currently no way to handle more than one CSS-Class for a RTE style definition.
The only way to handle this, is creating new CSS classes and extend the available button styles via LESS or SCSS.
In TYPO3 7 you can use this following RTE configuration to use multiple classes. The magic happens in the class-definition with the attribute "required"
RTE {
default {
proc.allowedClasses := addToList(btn-dark)
buttons.link.properties.class.allowedClasses := addToList(btn-dark)
}
classes.btn-dark {
name = Dark-Button
requires = btn btn-small
}
classesAnchor.buttonDark {
class = btn-dark
type = page
}
}

how to show the locale that the browser is showing in gwt I18N?

i'm doing i18n to my application i did something that is shown in showcase example i'm using the listbox to show different locales, the problem is when i'm swapping from one locale to another locale,locale is changing but the list box is not showing the locale in which i am, it is showing first element of the list every time as it is reloading
here is code:
#Override
public void changeSwap() {
final String queryParam = LocaleInfo.getLocaleQueryParam();
String locale=getView().getLocale().getValue(getView().getLocale().getSelectedIndex());
Log.info("revealed locale is"+locale);
if (queryParam != null) {
UrlBuilder builder = Location.createUrlBuilder().setParameter(
queryParam, locale);
Window.Location.replace(builder.buildString());
} else {
// If we are using only cookies, just reload
Window.Location.reload();
}
}
i didn't find any method in listbox api to do it
thanks
You're using a part of the code from the Showcase (ShowcaseShell.initializeLocaleBox()), but the part that is responsible for selecting the correct value in the ListBox is this:
String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
if (currentLocale.equals("default")) {
currentLocale = "en";
}
String[] localeNames = LocaleInfo.getAvailableLocaleNames();
for (String localeName : localeNames) {
if (!localeName.equals("default")) {
String nativeName = LocaleInfo.getLocaleNativeDisplayName(localeName);
localeBox.addItem(nativeName, localeName);
if (localeName.equals(currentLocale)) {
localeBox.setSelectedIndex(localeBox.getItemCount() - 1);
}
}
}
Make sure to add it to your code before adding the ChangeHandler to the localeBox.
Here's the full setup in the Showcase 2.4.0 example:
Showcase.gwt.xml 21-28 performs the locale setup for the module (especially it defines the available locales as "en", "ar", "fr", "zh")
ShowcaseShell.ui.xml 204-206 creates the ListBox widget.
ShowcaseShell.java 113-114, 190, 322-364 fill the available locales into the ListBox, and adds a ChangeHandler.
I would recommend to create a simple new GWT project (at first without gwtp or anything special) and just add these bits of code. Then you can try to migrate the setup to your full project.

How to setup multiple Layouts in Zend Framework. Eg. Public/Logged in/Various combinations of modules

I know & used the very basic Zend Framework's Layouts where I used 1 layout throughout the whole site. But now I need a more intermediate/organized setup.
The public site layout will have the div#mainContent taking up the whole 12 columns (using 960gs)
The logged in site will have div#mainContent taking up 9 columns + side bar with 3 columns
In the sidebar of the logged in site, various pages may contain various modules (not Zend Framework's modules, more like "boxes/widgets")
They will have different nav menus too
I am thinking of using 1 base layout where the 2 sub layouts will "extend". The base layout will just contain the <html> declarations headScripts etc till the <body> then the sublayouts will contain definations for the wrapping divs div.grid_12, grid_9, grid_3. How can I implement this "extending", basically, I just want to reuse code
Also whats a good way to render sidebar boxes/widgets
I'm switching between layouts depending on the subdomain of my website.
Here's the layout plugin I'm using...
class App_Layout_Controller_Plugin_Layout extends Zend_Layout_Controller_Plugin_Layout
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$layout = $this->getLayout();
$filename = $layout->getLayoutPath() . '/' . $request->getModuleName() . '.' . $layout->getViewSuffix();
//check if the layout template exists, if not use the default layout set in application.ini
if (file_exists($filename))
{
$this->getLayout()->setLayout($request->getModuleName());
}
}
}
Of course you can modify this for your own needs.
Make sure you set up you application.ini correctly too including elements like the following...
resources.layout.layout = "default"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.pluginClass = "App_Layout_Controller_Plugin_Layout"
In my case I have:
default.phtml, admin.phtml, clients.phtml
I hope this helps...
Angel
The way we are doing it, which I'm not sure if it's the best approach, is to set the current layout within the init() method available in each controllers.
So for example in case we have this URL: www.mysite.com/social/
class SocialController extends BaseController
{
public function init(){
$layout = $this->_helper->layout();
$layout->setLayout('social');
}
}
Then within the config.ini:
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
And there is a socia.phtml defined within the resources.layout.layoutPath