(I am very new to php, so please forgive my blatant ignorance.)
My portfolio site theme uses this array to display realted images. Currently the theme crops those images to squares. 'images_proportion' => 'marceau_core_image_size_square',
I would like to be able to control the size and proportions of these. Any thoughts on how I might do this would be greatly apreciated.
<div id="qodef-portfolio-single-related-items">
<h4 class="qodef-m-title"><?php echo esc_html__('Related projects', 'marceau-core') ?></h4>
<?php
$params = apply_filters(
'marceau_core_filter_portfolio_single_related_posts_params',
array(
'custom_class' => 'qodef--no-bottom-space',
'columns' => '4',
'posts_per_page' => 4,
'additional_params' => 'id',
'post_ids' => $related_posts['items'],
'layout' => 'info-on-hover',
'hover_animation_info-on-hover' => 'roll-out',
'title_tag' => 'h5',
'behavior' => 'columns',
'images_proportion' => 'marceau_core_image_size_square',
'image_source' => 'featured',
)
);
echo MarceauCore_Portfolio_List_Shortcode::call_shortcode( $params );
?>
</div>
I tried replaceing 'marceau_core_image_size_square' with actual ratios, like '16:9'. And I tried adding height and width to the array, but these megar efforts had no effect.
Related
I'm new to TYPO3 (first project) and I have some understanding issues of the creation of a custom element with a colorpicker. In this project I already have created a few elements but I only use predetermined fields for the backend input. For the element I need next I need the user to choose a color. I haven't found a fitting existing element. My setup that doesn't work is in the TCA/Overrides/tt_content.php file and looks like this.
$GLOBALS['TCA']['tt_content']['item_0']=array();
$GLOBALS['TCA']['tt_content']['item_0']['label']='Color';
$GLOBALS['TCA']['tt_content']['item_0']['config']=array();
$GLOBALS['TCA']['tt_content']['item_0']['config']['type']='input';
$GLOBALS['TCA']['tt_content']['item_0']['config']['renderType']='colorpicker';
$GLOBALS['TCA']['tt_content']['item_0']['config']['size']=10;
$GLOBALS['TCA']['tt_content']['types']['wo_mitem'] = array(
'showitem' => '--palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.general;general,
header;Title,
subheader;Background,
header_link;Target,
item_0;Color,
bodytext;Text;;richtext:rte_transform[flag=rte_enabled|mode=ts_css]
');
The item_0 was a try to create a colorpicker but it doesn't seem to work. Do I need something different in a different file? The first few lines I added to define my field. Is there a better way to do this?
All other files in my custom extension work (since all other custom elements work fine). The only difference is, as said, the need of a way to choose a color in the new one.
Just for a clearer look here the other files
setup.txt:
lib.contentElement {
templateRootPaths {
100 = EXT:wostyle/Resources/Private/Template
}
}
tt_content {
wo_mitem < lib.contentElement
wo_mitem {
templateName = MItem
}
}
tt_content.php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
array(
'WO_Item (ItemBox, Text only)',
'wo_mitem',
'content-image'
),
'CType',
'wostyle'
);
$GLOBALS['TCA']['tt_content']['item_0']=array();
$GLOBALS['TCA']['tt_content']['item_0']['label']='Farbe';
$GLOBALS['TCA']['tt_content']['item_0']['config']=array();
$GLOBALS['TCA']['tt_content']['item_0']['config']['type']='input';
$GLOBALS['TCA']['tt_content']['item_0']['config']['renderType']='colorpicker';
$GLOBALS['TCA']['tt_content']['item_0']['config']['size']=10;
$GLOBALS['TCA']['tt_content']['types']['wo_mitem'] = array(
'showitem' => '--palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.general;general,
header;Bezeichnung,
subheader;Chemische Bezeichnung,
header_link;Zielseite,
item_0;Farbe,
bodytext;Text;;richtext:rte_transform[flag=rte_enabled|mode=ts_css]
');
typo.ts
mod.wizards.newContentElement.wizardItems.wo_extra {
header = WO Elemente
after = common
elements {
wo_mitem {
iconIdentifier = content-image
title = WO_Item (ItemBox, Text only)
description = Ein Produktfeld mit Text
tt_content_defValues {
CType = wo_mitem
}
}
}
show := addToList(wo_mitem)
}
MItem.html
<div class="item-text">
<f:link.typolink parameter="{data.header_link}">
<div class="item-front">
<f:if condition="{data.subheader}!=''">
<f:then>
<div class="item-bg">
<f:format.html>{data.subheader}</f:format.html>
</div>
</f:then>
</f:if>
<div class="item-title">
<f:format.html>{data.header}</f:format.html>
</div>
</div>
<div class="item-back">
<f:format.html>{data.bodytext}</f:format.html>
</div>
</f:link.typolink>
</div>
<f:debug>{data}</f:debug>
EDIT: I use typo3 8.7.8
I did not check your whole code but I have a working color-picker on a field ...
you're close but an error that pops up right away is that your item should be placed under ['columns'] ...
$GLOBALS['TCA']['tt_content']['columns']['item_0']=array();
next you are missing the refference to the wizard !! (you should adopt the annotation with square brackets which shows much more the structure)
this should be stored in Configuration/TCA/Overrides/tt_content.php: (when you override existing fields, otherwise you have a dedicated code for the element)
<?php
/***************
* Modify the tt_content TCA
*/
$tca = [
'columns' => [
'item_0' => [
'label' => 'Color',
'config' => [
'type' => 'input',
'size' => 10,
'eval' => 'trim',
'default' => '#ffffff',
'wizards' => [
'colorChoice' => [
'type' => 'colorbox',
'title' => 'LLL:EXT:lang/locallang_wizards:colorpicker_title',
'module' => [
'name' => 'wizard_colorpicker'
],
'dim' => '20x20',
'JSopenParams' => 'height=600,width=380,status=0,menubar=0,scrollbars=1',
],
],
],
],
],
];
$GLOBALS['TCA']['tt_content'] = array_replace_recursive($GLOBALS['TCA']['tt_content'], $tca);
With the help of webMan and some internet searches I could adopt my code a little.
I added the file "ext_tables.sql" with the content
CREATE TABLE tt_content (
item_0 varchar(10) DEFAULT '' NOT NULL,
);
And changed the tt_content.php in TCA/Overrides to:
$temporaryColumns = Array(
"item_0" => Array(
'label' => 'Color',
'config' => Array(
'type' => 'input',
'renderType' => 'colorpicker',
'size' => 10
)
)
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content',$temporaryColumns);
$GLOBALS['TCA']['tt_content']['types']['wo_mitem'] = array(
'showitem' => '--palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.general;general,
header;Bezeichnung,
subheader;Chemische Bezeichnung,
header_link;Zielseite,
item_0;Farbe,
bodytext;Text;;richtext:rte_transform[flag=rte_enabled|mode=ts_css]
');
There are still a view things missing in compare to webMans code but at least this is the first working version I have so i figured i show it since my question is answered:).
I want an image on the right, text on the left floating around the image. The other way round works pretty good, there also is an example for that on the Recipies section in the documentation. However, I did not get this working with images floating on the right. What I tried:
addImage('myimage.png',
array(
'width'=>320,
'height'=>240,
'align'=>'right',
'wrappingStyle'=>'square',
'positioning' => 'absolute'
)
);
or
addImage('myimage.png',
array(
'width'=>320,
'height'=>240,
'align'=>'right',
'wrappingStyle'=>'square',
'positioning' => 'absolute',
'posHorizontalRel' => 'margin',
'posVerticalRel' => 'line'
)
);
I also experimented with negative image widths etc., but that did not work neither. Unfortunately, documentation on the whole project is really poor, at least at phpword.readthedocs.org.
I had the same problem too, and there's no answer on the internet to this date. So here's what I came up with:
$section->addImage('image.png', array(
'width' => 40,
'height' => 40,
'wrappingStyle' => 'square',
'positioning' => 'absolute',
'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_RIGHT,
'posHorizontalRel' => 'margin',
'posVerticalRel' => 'line',
));
I'm a beginner in writing PHP, but working on developing themes in WordPress.
I have no idea how to echo my style option within my front-page.php.
My meta.php:
$meta_style = array();
$meta_style['meta_style'] = array(
'dash_icon' => 'list-view',
'title' => __('Section Settings', 'fluent'),
'description' => __('These are general section settings.','fluent'),
'context' => 'normal',
'priority' => 'high',
'option_name' => 'meta_style',
'caps' => array(),
'fields' => array(
'style' => array(
//...
'type' => 'select',
'options' => array(//option value = option label
'value' => 'white',
'value2' => 'black'
),
'multiple' => false,//allow multiple values to be selected - default false
'placeholder' => 'white'//placeholder text for the element
),
),
);
My front-page.php (it's wrapped in a BUTTON just a see if the variable echoes):
<button>
<? if($meta = get_post_meta($post->ID)){ if($meta['style'] == true){ echo $meta['value']; } } ?>
</button>
Can anyone provide an additional examples on how to echo other types, such as 'type' => 'text'?
I dont know exactly what you want, but you should:
1 - See if you're echoing the right information
2 - Use var_dump()
In your first code example you have a variable $meta_style which is a map. It has one key, 'meta_style' that leads to a next map. Inside that inner map you have the keys 'dash_icon' and so on. So for example this should echo the string 'normal':
echo $meta_style['meta_style']['context'];
However, in your second example, you have a variable $meta which is also a map, having keys 'style' and 'value'. You could echo those with:
echo $meta['style'];
echo $meta['value'];
Based on your example, I have no idea what these should do or how they should be related, or what their meaning should be.
I simply need to print out an image via php in Drupal 7. I already have 3 presets, thumnail, medium and large. Does anyone know the exact code I need to print these out as I cannot seem to work it out?
As far as I know, in Drupal 6 it was something like this:
<img src="<?php print 'sites/default/files/imagecache/**thumbnail**/' . $node->field_image_cache['0']['filepath']; ?>" />
I'd be very grateful for any help.
Use theme_image_formatter.
E.g.
print theme("image_formatter", array(
'image_style' => 'thumbnail',
'item' => array(
'uri' => 'sites/default/files/image.jpg',
'alt' => t(""),
'title' => t(""),
'attributes' => array(),
),
));
I'am trying to generate thumbnails with uploaded images in CakePHP.
I have worked with Rails and I used paperclip for that purpose, is there any way to do the same with CakePHP?
to be clear, I want to shrink the images keeping the ratio and then crop them in order to get them in the size I want.
If you have PHP available, you can try phpThumb, which does all that for you and much more. It can crop, zoom-crop, transform, blur, contrast...etc etc, and it auto-creates the thumbnails and keeps them in cache so it doesn't have to re-crop...etc each time the image is loaded.
It's also VERY simple to install and use, which is a big plus.
For CakePHP, you can just put the phpthumb folder in your webroot/ directory and use it just like normal.
Sounds like you might be looking for something like my Polyclip plugin. It's not feature-complete so I haven't documented it very well yet (I'll work on that as soon as I can), but it is in production and the core functionality that's in place seems to do what I need. Here's how I have it deployed with an Attraction model.
public $actsAs = array(
'Polyclip.attachable' => array(
'Image' => array(
'Thumbnails' => array(
'medium' => array( 'width' => 250, 'height' => 250, 'method' => 'resize_to_fit' ),
'square' => array( 'width' => 100, 'height' => 100, 'method' => 'resize_to_fill' ),
'sidebar' => array( 'width' => 290, 'height' => 100, 'method' => 'resize_to_fill' )
)
)
)
);
This attaches an image to the attraction with 3 thumbnails created automatically. As I said, it's not documented, but it's out there to fill the need you're looking to fill.