TYPO3: added new language and get 404 page not found - multilingual

I added a new website language to a TYPO3 project. The new website language has id=2. But if I call e.g. www.your-domain.com/hr.html I get 404 - page not found (normally the start page in the translated language should appear). Also the menus show the links without /hr/. I can call the pages with http://www.your-domain.com/index.php?L=2. The configuration for Typo3 looks like
config {
linkVars = L
sys_language_mode = content_fallback
sys_language_overlay = hideNonTranslated
sys_language_uid = 0
language = de
locale_all = de_DE
htmlTag_langKey = de-DE
}
[globalVar = GP:L=1]
config {
sys_language_uid = 1
language = en
local_all = en_GB
htmlTag_langKey = en-GB
}
[global]
[globalVar = GP:L=2]
config {
sys_language_uid = 2
language = hr
local_all = hr_HR
htmlTag_langKey = hr-HR
}
[global]
The RealURL configuration is
'preVars' => array (
'0' => array (
'GETvar' => 'no_cache',
'valueMap' => array (
'nc' => '1',
),
'noMatch' => 'bypass'
),
'1' => array (
'GETvar' => 'L',
'valueMap' => array (
'de' => '0',
'en' => '1',
'hr' => '2',
),
'valueDefault' => 'de',
'noMatch' => 'bypass',
),
'2' => array (
'GETvar' => 'lang',
'valueMap' => array (
'de' => '0',
'en' => '1',
'hr' => '2',
),
'valueDefault' => 'de',
'noMatch' => 'bypass',
),
For me it looks like that everything should work, but it isn't. I also cleared the RealURL Cache with
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearAllCache_additionalTables']['tx_realurl_urldecodecache'] = 'tx_realurl_urldecodecache';
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearAllCache_additionalTables']['tx_realurl_urlencodecache'] = 'tx_realurl_urlencodecache';
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearAllCache_additionalTables']['tx_realurl_pathcache'] = 'tx_realurl_pathcache';
in the localconf.php and pressing the Clear all caches button. I'm using realurl 1.12.1 and Typo3 4.5.5. I also looked into the htaccess and didn't found anything special. What I'm missing?

On the page urltool was removed but the include of urltoolconf_realurl.php was still there (with the old settings). This include in the localconf.php has overwritten my settings of realurl_conf.php (which included the new language).
But still some menus have index.php?id=69&L=2 in the URL instead of the speaking URL. So they were links to other pages and I had to set the links again and make sure there was a translation available (even in folders ...).

Related

Drupal 7 views exposed filter not working

I made a view with the view UI in drupal then I exported the code and created a custom module implementing hook_views_default_views() and making some changes. The view works fine and I have a lot of filters. All work except 1, a type: grouped filter
$handler->display->display_options['filters']['field_FIELDNAME_tid']['id'] = 'field_FIELDNAME_tid';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['table'] = 'field_data_field_FIELDNAME';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['field'] = 'field_FIELDNAME_tid';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_FIELDNAME_tid']['expose']['operator_id'] = 'field_FIELDNAME_tid_op';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['expose']['label'] = 'Field Label';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['expose']['operator'] = 'field_FIELDNAME_tid_op';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['expose']['identifier'] = 'field_FIELDNAME_tid';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['expose']['remember_roles'] = array(
2 => '2',
1 => 0,
3 => 0,
);
$handler->display->display_options['filters']['field_FIELDNAME_tid']['is_grouped'] = TRUE;
$handler->display->display_options['filters']['field_FIELDNAME_tid']['group_info']['label'] = 'Field Label';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['group_info']['identifier'] = 'field_FIELDNAME_tid';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['group_info']['group_items'] = array(
1 => array(
'title' => 'Test',
'operator' => 'or',
'value' => array(
2630 => '2630',
2631 => '2631',
),
),
);
$handler->display->display_options['filters']['field_FIELDNAME_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['vocabulary'] = 'VOCABULARY_NAME';
$handler->display->display_options['filters']['field_FIELDNAME_tid']['hierarchy'] = 1;
The view works and has no errors or notices, all filters display and work fine except this one.
After a couple of hours .. I found that it was a view issue https://www.drupal.org/node/2224601
The solution is to Just check allow multiple selections, save view, and then un-check multiple selections this will put this line into the view:
$handler->display->display_options['filters']['field_FIELDNAME_tid']['expose']['multiple'] = TRUE;

MeioUpload isn't creating thumbnails in cakephp 2.4

I'm using meioupload and everything works well till I try to make thumbnails. Then I can see only kind of phpThumb error message which says
"C:/wamp/cakephp/vendors/phpTmub/img/uploads/product/filename/image.png" does not exist
I'm new with cakePHP so I never faced this problem before. Does anyone know what should I do?
here is my model code:
var $actsAs = array(
'MeioUpload' => array(
'filename' => array(
'create_directory' => true,
'allowed_mime' => array('image/jpeg', 'image/pjpeg', 'image/png'),
'allowed_ext' => array('.jpg', '.jpeg', '.png'),
'zoomCrop' => true,
'thumbsizes' => array(
'normal' => array('width' => 400, 'height' => 300),
'small' => array('width' => 80, 'height' => 80,'maxDimension' => '', 'thumbnailQuality' => 100, 'zoomCrop' => true),
),
'default' => 'default.jpg'
)
));
UPDATE:
I found special phpThumb for cakePHP 2.0 so the Path changed into this:
"C:/wamp/cakephp/img/uploads/product/filename/image.png"
and if I open default image in my browser th path is like:
localhost:8080/cakephp/img/uploads/product/filename/image.png
Thanks
I solved the problem, maybe not very elegant, but it works!
For the first time, as I said, I downloaded special version of phpThumb for cakePHP.
Here is link: https://github.com/simkimsia/phpThumb-for-cakephp-2.0
After there was my problem with the path because my images was in folder: C:\wamp\www\cakephp\app\webroot\img\uploads\product\filename\image.png
So I had to find this part of code(begins on line 1078):
if ($this->useCake) {
if ($this->config_document_root != null) {
$AbsoluteFilename = $this->config_document_root.DIRECTORY_SEPARATOR.$filename;
} else {
$AbsoluteFilename = WWW_ROOT.DIRECTORY_SEPARATOR.$filename;
}
}
And edit a the path to fit into my folder:
$AbsoluteFilename = $this->config_document_root.DIRECTORY_SEPARATOR.'cakephp'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'webroot'.DIRECTORY_SEPARATOR.$filename;
$AbsoluteFilename = WWW_ROOT.DIRECTORY_SEPARATOR.'cakephp'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'webroot'.DIRECTORY_SEPARATOR.$filename;
and now its working perfectly...
after try many things.. and finally read the answer of Jan Omacka, i only have to edit phpthumb.class.php, line 223 in the constructor function phpThumb()
First
// public: constructor
function phpThumb() {
.....
//comment line
//$this->config_document_root = (!empty($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : $this->config_document_root);
.....
}
//and put the constant CakePHP Var WWW_ROOT (Full path to the webroot.)
$this->config_document_root = WWW_ROOT;
//and if this don't work.. put your real path in linux, or windows
//$this->config_document_root = '/srv/www/htdocs/sic/app/webroot/';
In my case inside webroot, have a folder with estructure 'Usuarios/ID_Prestamo/IDUsuario/', all works great uploading the picture but thumbs not.. so after download the last version of phpThumb, i saw that show an error of File does not exist (URL misformat, for original JPG File), after that download the special versiĆ³n for CakePhp and change the lines as mentioned.. and all works... I use OpenSuse Linux, Apache2, with Cake 2.4.2
Notes: I verified that if not have zoomCrop it not works, this is my structure
'dir' => 'galeria/', //main folder webroot/galeria/
'createDirectory' => true,
'maxSize'=>'5 Mb',
'allowedExt' => array('.jpg','.jpeg','.png'),
'zoomCrop' => true,
'thumbsizes' => array(
'small' => array('width'=>165, 'height'=>115),
'medium' => array('width'=>800, 'height'=>600)
),

Themeless Page - Or a content-only content type

I need to create content that only outputs what I entered, no layout, no comments, blocks, etc.
If I could implement a custom content type that used blank templates that might work, but I've been unable to make it work so far as overriding the themes seems to replace everything site-wide. So, skipping that, is there a simple way I'm not aware of, to just output what I type in the content's body, with no layout/blocks/comments,etc.
Is it possible via a custom module to add a custom field at the bottom, and then during the process_page() hook, ignore the theming and layout and just output the content?
Please don't suggest "Views" as it's not stable.
Some example use cases:
A page that's a PHP type, and it's simply a script that I don't want layout as an example.
Or if I have some json data to return.
Or if I want to toss up a all-in-one page with it's own theme.
Any suggestions?
I am working on a module that will do this and also integrate with views so you can set a view to be "theme-less" as well. I have it so that it will create a checkbox on a node form that you can specify the node to be theme-less node. Once that is checked, the node will be displayed with no theme (the content only, no title).
It's a little hackish, but it works preliminarily. I will be fleshing this out as I have need for it and I will likely also integrate it with views over time.
timeless.install
<?php
/**
* themeless.install
* defines our schema for flagging nodes as being themeless or not.
*/
function themeless_schema() {
$schema['themeless_node'] = array(
'description' => 'Keeps track of which nodes are themeless.',
'fields' => array(
'nid' => array(
'description' => 'The node id of a themeless node',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary_key' => array('nid'),
);
return $schema;
}
function themeless_enable() {
if (db_table_exists('themeless_node') == FALSE) {
drupal_install_schema('themeless');
}
}
function themeless_uninstall() {
drupal_uninstall_schema('themeless');
}
timeless.module
function themeless_process(&$variables, $hook) {
if ($hook == 'page') {
if (isset($variables['page']['content']['system_main']['nodes']) && is_array($variables['page']['content']['system_main']['nodes'])) {
$node = $variables['page']['content']['system_main']['nodes'];
$nodes = array_keys($node);
$result = db_query("SELECT t.nid AS themeless, n.promote
FROM {themeless_node} t, {node} n
WHERE t.nid=:nid
AND n.nid=t.nid",
array('nid' => $nodes[0]));
$tdata = $result->fetchObject();
if (isset($tdata->themeless) && $tdata->themeless > 0 && $tdata->promote != 1) {
if ($node[$nodes[0]]['body']['#object']->body['und'][0]['format'] == 'php_code') {
print $node[$nodes[0]]['body'][0]['#markup'];
} else {
print $node[$nodes[0]]['body']['#object']->body['und'][0]['value'];
}
exit();
}
}
}
}
function themeless_form_alter(&$form, &$form_state, $form_id) {
$parts = explode('_',$form_id);
$form_type = $parts[count($parts)-1].'_'.$parts[count($parts)-2];
$themeless = '';
if ($form_type == 'form_node') {
if (isset($form_state['node']->nid) && $form_state['node']->nid) {
$themeless = db_query("SELECT COUNT(*) AS themeless
FROM {themeless_node}
WHERE nid=:nid",
array('nid' => $form_state['node']->nid))->fetchField();
}
$checked = ($themeless == 1) ? 'checked' : '';
$form['themeless'] = array(
'#type' => 'fieldset',
'#title' => t('Themeless Node'),
'#weight' => 5,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['themeless']['themeless_node'] = array(
'#type' => 'checkbox',
'#title' => 'Themeless Node',
'#description' => 'This theme will be displayed without any wrapper themes.',
'#weight' => 100,
'#default_value' => $themeless,
);
}
}
function themeless_node_insert($node) {
$result = db_query("INSERT INTO {themeless_node} (nid)
VALUES( :nid )",array('nid' => $node->nid));
}
function themeless_node_update($node) {
if ($node->themeless_node == 1) {
if (db_query("SELECT COUNT(*) AS themeless
FROM {themeless_node}
WHERE nid=:nid",
array('nid' => $node->nid))->fetchField() != 1) {
$result = db_query("INSERT INTO {themeless_node} (nid)
VALUES( :nid )",array('nid' => $node->nid));
}
} else {
$result = db_query("DELETE FROM {themeless_node}
WHERE nid=:nid",array('nid' => $node->nid));
}
}
timeless.info
name = Themeless
description = Gives the option to a node to have a themeless display or displayed without the various theme templates native to Drupal.
core = 7.x
version = 7.x-1.0dev

Is the db in $this->db->last_insert() the class or the constant?

Since I am using 2 databases I have 2 separate config setups in config/database.php and load them in the Model's constructor with
$this->DB1 = $this->load->database('default', TRUE);
$this->DB2 = $this->load->database('reserve', TRUE);
I need to retrieve the id of the last inserted record and have used $this->db->last_insert();
and $this->DB2->last_insert();
but neither is working.
My insert query works fine and is
$insArray = array(
'propNumber' => $prp,
'fname' => $fname,
'lname' => $lname,
'unit' => $unit,
'email' => $email,
'NOC' => 0
);
$this->DB2->insert('users', $insArray);
$last_id = $this->db->last_insert();
$_SESSION['userID'] = $last_id;
return 'valid';
http://php.net/manual/en/function.mysql-insert-id.php
$last_id = $this->DB2->mysql_insert_id();

How to translate a Drupal Bean programmatically?

I've looked everywhere, but I can't find a way to translate a bean. They rely on entity_translation, but this doesn't seem to work:
$form_state['build_info']['args'] = array ( 0 => $bean );
$form_state['form_id'] = 'bean_form';
$form_state['entity_translation'] = array(
'form_langcode' => $newLangcode,
'source_langcode' => 'en',
'is_translation' => 1,
);
drupal_form_submit('bean_form', $form_state);
It doesn't do anything. Any ideas what I could be missing? Or is there perhaps a better way than trying to submit the form?
My attempt is basically just an attempt at trying to mimmick what happens on this page:
/block/MY_BLOCK/edit/add/en/es
Took me forever to find this:
$translation = array(
'translate' => 0,
'status' => 1,
'language' => $langCode, // here is the language you're translating to
'source' => 'en',
);
$bean = bean_load($bid);
$handler = entity_translation_get_handler('bean', $bean);
$values = array (
// i add the default values here, but you can add whatever you want
);
$handler->setTranslation($translation, $values);
bean_save($bean);

Resources