Can't fetch image url to use in my fluid image viewhelper - fluid

I have a problem with fetching an image url to use in my fluid view helper:
My view helper looks like this:
<f:image src="{f:cObject(typoscriptObjectPath:'plugin.tx_contentelements.slidePath', data:'{data.uid}')}" class="slideshow-image" alt="{data.header}" />
and my TS looks like this:
plugin.tx_contentelements.slidePath = FILES
plugin.tx_contentelements.slidePath {
references {
table = tt_content
uid.data = uid
fieldName = image
}
begin = 0
maxItems = 1
renderObj = IMG_RESOURCE
renderObj {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 900
}
}
}
the problem is probably the uid.data = uid. I saw this in an example, but it does not seem to work for me.

hmm untested but have you tried this?
...uid.field instead of uid.data... or you do it like this: uid.data = field:uid
plugin.tx_contentelements.slidePath {
references {
table = tt_content
uid.field = uid
fieldName = image
}
maybe it helps

Related

I want to get a variable in typoscript select Query

The title says it all; I need a Typoscript SQL SELECT query with a dynamic WHERE clause.
I get the UID of the current logged in user with:
data = TSFE:fe_user|user|uid
But how can I use that in a database query?
I store the UID in a typoscript variable named {userID}.
That's my code so far. The Problem is Typoscript just merge the two values:
// User One has value: 50
// User Two has value: 32
// With this code the output is : 5032 ????
lib.coins = CONTENT
lib.coins {
table = fe_users
select {
pidInList = 18
where = uid
andWhere.insertData = TSFE:fe_user|user|uid
selectFields = coins
}
renderObj = COA
renderObj {
1 = TEXT
1.field = coins
}
}
You should make use of the select option markers:
lib.coins = CONTENT
lib.coins {
table = fe_users
select {
selectFields = coins
pidInList = 18
where = uid = ###UID###
markers {
UID.data = TSFE:fe_user|user|uid
}
}
renderObj = COA
renderObj {
1 = TEXT
1.field = coins
}
}

if i upload image then edit work fine but if i update other field and not image that time it display array to sting erro in cakephp2.4.5

it will display error if i update other filed and not image.
public function edit($id = null) {
$this->helpers = array('TinyMCE.TinyMCE');
$this->layout = 'adminpanel';
if (!$id) {
throw new NotFoundException(__('Invalid post'));
}
$this->layout = 'adminpanel';
//save data
if ($this->request->is(array('post', 'put'))) {
$this->Tour->id = $id;
//Save image
if(is_uploaded_file($this->request->data['Tour']['varbigimg']['tmp_name']))
{
$fileNameFull = $this->request->data['Tour']['varbigimg']['name'];
$uploadFolder = "upload";
//full path to upload folder
$uploadPath = WWW_ROOT . $uploadFolder;
$oldFile = $uploadPath.'/'.$fileNameFull;
move_uploaded_file(
$this->request->data['Tour']['varbigimg']['tmp_name'],$oldFile
);
$newFile = WWW_ROOT.'courseImages/thumb/'.$fileNameFull;
$image = new ImageResizeComponent();
$quality = 100; // image resize for thumb
$height = 40;
$width = 60;
$this->ImageResize->resize($oldFile, $newFile, 60,60,$quality);
$this->request->data['Tour']['varbigimg'] = $fileNameFull;
}
else{//Img not uploaded
$this->request->data['Tour']['vartitle']= $this->data['Tour']['vartitle'];
$this->request->data['Tour']['varsubtitle']= $this->data['Tour']['varsubtitle'];
$this->request->data['Tour']['txtsortdesc']= $this->data['Tour']['txtsortdesc'];
$this->request->data['Tour']['txtdeasc']= $this->data['Tour']['txtdeasc'];
$this->request->data['Tour']['vardeparts']= $this->data['Tour']['vardeparts'];
$this->request->data['Tour']['decadultprice']= $this->data['Tour']['decadultprice'];
$this->request->data['Tour']['decchildprice']= $this->data['Tour']['decchildprice'];
$this->request->data['Tour']['varimgtitle']= $this->data['Tour']['varimgtitle'];
$this->request->data['Tour']['enumstatus']= $this->data['Tour']['enumstatus'];
$this->request->data['Tour']['id']= $this->data['Tour']['id'];
//In this way do for All Except Image.
}
// pr($this->$this->request->data);
if ($this->Tour->save($this->request->data)) {
$this->Session->setFlash(__('Unable to add your schedule.'));
//Save image
$this->Session->setFlash(__('Your tour has been updated.'));
return $this->redirect(array('controller'=>'admin','action' => 'tour'));
$this->Session->setFlash(__('Unable to update your Tour.'));
}
}
$tour = $this->Tour->findByid($id);
if (!$tour) {
throw new NotFoundException(__('Invalid post'));
}
if (!$this->request->data) {
$this->request->data = $tour;
}
}
my cont code
my view is below. so when i upload image it will work fine. but in edit if i dont upload image then it display array to sting error. means it not take ast image. thanks
echo $this->Form->create('Tour',array('autocomplete' => 'off','enctype'=>'multipart/form-data'));
echo $this->Form->input('varbigimg',array('type' => 'file'));?>
Write Else for
if(is_uploaded_file($this->request->data['Tour']['varbigimg']['tmp_name']))
{
.........
}else{
//**TWO GOLDEN LINES OF YOUR LIFE**
$tourForImg = $this->Tour->findByid($id);
$this->request->data['Tour']['varbigimg'] = $tourForImg['Tour']['varbigimg'];
//**TWO GOLDEN LINES OF YOUR LIFE**
//AS Img not uploaded by user
//Write All data EXPLICITELY that you want to save WITHOUT Image.
$this->request->data['Tour']['Tourname']= $this->data['Tour']['Tourname'];
$this->request->data['Tour']['YourFormField1']= $this->data['Tour']['YourFormField1'];
$this->request->data['Tour']['YourFormField2']= $this->data['Tour']['YourFormField2'];
//In this way do for All Except Image.
}

Add caption to TYPO3 renderObj for slider

I am using this little snippet for a slider:
table = tt_content
select {
where = colPos = 0
orderBy = sorting
languageField = sys_language_uid
}
renderObj = FILES
renderObj {
references {
table = tt_content
fieldName = image
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:publicUrl
stdWrap.typolink.parameter.data = file:current:link
stdWrap.wrap = <li>|</li>
}
}
Works great and I like that it's very compact other than much more complex code I found around.
I would now like to add the imagecaption field to display text within a slide, but could not get it work.
Does anyone has a hint on that?
That depends on where your slider wants to take the caption from. If it can get it from the title or alt tag of your image, you could just add the caption to your renderObj:
renderObj = IMAGE
renderObj {
file.import.data = file:current:publicUrl
titleText = file:current:caption
stdWrap.typolink.parameter.data = file:current:link
stdWrap.wrap = <li>|</li>
}
or
renderObj = IMAGE
renderObj {
file.import.data = file:current:publicUrl
altText = file:current:caption
stdWrap.typolink.parameter.data = file:current:link
stdWrap.wrap = <li>|</li>
}
If you need to have it inside an own tag, you should go for the COA approach as suggested by Urs:
renderObj = COA
renderObj {
10 = IMAGE
10 {
file.import.data = file:current:publicUrl
stdWrap.typolink.parameter.data = file:current:link
}
20 = TEXT
20 {
data = file:current:caption
wrap = <span class="imagecaption">|</span>
}
wrap = <li>|</li>
}
the fieldname just isn't caption, but description:
file:current:description

TYPO3 - parent page field for title in typolink

I have a problem with TYPO3 which I encountered several times now.
If i fetch an object with the TYPO3 CONTENT Object i have the possibility to render the fields with the renderObj...
So far so good...
But if i try to fetch an object which i fetched already before i dont get any response..
Following setup:
temp.current = COA
temp.current {
10 = CONTENT
10 {
table = pages
select {
pidInList = 22
max = 1
}
renderObj = COA
renderObj {
10 = CONTENT
10 {
table = tt_content
select {
pidInList.field = uid
where = colPos = 9
max = 1
languageField = sys_language_uid
}
renderObj = COA
renderObj {
5 = TEXT
5 {
value = here
typolink {
parameter.field = pid
title {
cObject = RECORDS
cObject {
tables = pages
source.field = pid
conf.pages = TEXT
conf.pages.field = title
}
}
}
}
20 = IMAGE
20 {
required = 1
file{
import = uploads/pics/
import.field = image
import.data = levelmedia: -1, slide
import.listNum = 0
width = 300c
height = 300c
}
titleText.field = titleText // altText
altText.field = altText // titleText
imageLinkWrap = 1
imageLinkWrap {
enable = 1
typolink {
parameter.data = field:pid
}
}
}
}
}
}
}
}
This is my current setup which i need to get a current project... Whatever..
The important part is:
5 = TEXT
5 {
value = here
typolink {
parameter.field = pid
title {
cObject = RECORDS
cObject {
tables = pages
source.field = pid
conf.pages = TEXT
conf.pages.field = title
}
}
}
}
I've already debugged the result of source... The value is 92, which is the correct uid from the page from where I need the title field...
Also I know that the code should be okay, because I use this snippet on many pages.
I think the problem is, that I try to fetch a content which i already fetched before..
Right here:
temp.current = COA
temp.current {
10 = CONTENT
10 {
table = pages
select {
pidInList = 22
max = 1
}
}
}
Many thanks!
// EDIT
I found a very good solution for my problem..
5 = TEXT
5 {
value = hier
typolink {
parameter.field = pid
title.cObject = TEXT
title.cObject {
data.dataWrap = DB:pages:{field:pid}:title
}
}
}
I found a solution!
5 = TEXT
5 {
value = hier
typolink {
parameter.field = pid
title.cObject = TEXT
title.cObject {
data.dataWrap = DB:pages:{field:pid}:title
}
}
}
According to http://forge.typo3.org/issues/20541 you are right and this has not been viewed as a bug but a feature ("recursion prevention").

ImageView.setImageURI method does not shown image on android

I am listing contacts with photo but i could not shown the photos of contacts. I get the photo uri as following:
ContentResolver cr = getContentResolver();
// Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,null, null,null );
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, ContactsContract.Contacts.DISPLAY_NAME + " ASC");
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
photo_id = cur.getInt(cur.getColumnIndex(ContactsContract.Contacts.PHOTO_ID));
Log.e("name", name);
Log.e("Photo_id", ""+photo_id);
photo = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, photo_id);
Log.e("URI", ""+photo);
image.setImageURI(photo); // Does not shown image.
...
}
}
A sample uri(printed in Log):
content://com.android.contacts/contacts/52
i do not know the reason why uri is not shown the images. please help me.
i have solved my problem using bitmap. the imageView.setImageURI is not used for me. so that is use the following code instead of setImageURI.
private Bitmap loadContactPhoto(ContentResolver cr, int id) {
Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id);
InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, uri);
if (input == null) {
return null;
}
return BitmapFactory.decodeStream(input);
}
Here id is the contact id , not photo id of the contact.