link an image in tt_news - image

I'm using TYPO3 4.2.8 and tt_news 2.5.2. I tried the following snippet:
plugin.tt_news.displaySingle {
image {
# turn off default popup anchor
imageLinkWrap = 0
# add our link to the first URL in links field
stdWrap.typolink {
parameter = {current:1}
parameter {
setCurrent.field = links
setCurrent.listNum = 0
insertData = 1
}
}
}
}
Then I added an image to my news and also put a link into the link field (in the tab relations).
<LINK http://www.yourwesite.com/fileadmin/user_upload/downloads/broschure.pdf _blank>Download brochure</LINK>
But if I look at the news I don't have a link on the image. What do I have to change to get it work with my old version of tt_news?
Edit:
Now I tried it with gernericmarkers (idea from this topic). My TS looks like the following:
temp.img = COA
temp.img.5 = IMAGE
temp.img.5 < plugin.tt_news.displaySingle.image
temp.img.5 {
required = 1
wrap = |
file {
import = uploads/pics/
import.field = image
import.listNum = 0
}
titleText.field = title
altText.field = title
if.isTrue.field = links
imageLinkWrap.typolink.parameter.data = field:links
}
plugin.tt_news.genericmarkers.imagewithlink < temp.img
The marker is working but there is no content displayed in the news. What is wrong with my TS?

I don't know if this works in your old tt_news version but at least from version 3.0+ you can simply use the marker <!--###LINK_ITEM###--> around your image <!--###LINK_ITEM###--> inside your template to link anything you like to the detail page.

Your first snippet works, but you have to insert the link without the tags into the link field.
e.g.
http://www.yourwesite.com/fileadmin/user_upload/downloads/broschure.pdf _blank

Related

Image duplicates itself when using appendParagraph in Google Script

I wrote a script to add an image from my Google Drive and some custom text to a Google Doc. (I got the image insertion code from here).
The resulting document is created ok, but my image is added twice for some reason...
function myFunction(e) {
var doc = DocumentApp.create('fileTest');
var body = doc.getBody();
var matchedFiles = DriveApp.getFilesByName('logo.png');
if (matchedFiles.hasNext()) {
var image = matchedFiles.next().getBlob();
var positionedImage = body.getParagraphs()[0].addPositionedImage(image);
}
body.appendParagraph('Test line of text for testing');
doc.saveAndClose();
}
However, if I get rid of my appendParagraph code (body.appendParagraph(t1);) I only get one image (but obviously without the paragraph of text I want)
What's going on here? And how do I add both one picture and my paragraph of text?
I have not even the slightest clue as to why, but I found a way to make this work.
Switching the order of my code seemed to do the trick. I simply moved the image-insertion code to the end (i.e., after the appendParagraph code), and it worked fine. No duplicate image!
function myFunction(e) {
var doc = DocumentApp.create('fileTest');
var body = doc.getBody();
body.appendParagraph('Test line of text for testing');
var matchedFiles = DriveApp.getFilesByName('logo.png');
if (matchedFiles.hasNext()) {
var image = matchedFiles.next().getBlob();
var positionedImage = body.getParagraphs()[0].addPositionedImage(image);
}
doc.saveAndClose();
}

Translate Extbase Extension with locallang.xlf, but nothing happens?

I'm using TYPO3 CMS 6.2.6 and a new fantastic Extbase Extension called "jobfair".
I've add my new templateRootPaths like this:
plugin.tx_jobfair {
view {
templateRootPaths {
100 = EXT:jobfair/Resources/Private/Templates/
101 = fileadmin/templates/ext/jobfair/Resources/Private/Templates/
}
partialRootPaths {
100 = EXT:jobfair/Resources/Private/Partials/
101 = fileadmin/templates/ext/jobfair/Resources/Private/Partials/
}
layoutRootPaths {
100 = EXT:jobfair/Resources/Private/Layouts/
101 = fileadmin/templates/ext/jobfair/Resources/Private/Layouts/
}
}
}
...
So I can edit the Templates and Partials for my specific Design. ALl other templates will load from /typo3conf/ext/jobfair/Resources/...
Everything works fine. I also copied the language-folder from the extension (typo3conf) to my fileadmn-folder (fileadmin/.../jobfair/Resources/Private/Language/).
I edit "locallang.xlf" and "de.locallang.xlf", for example:
partial: ContractType.html
<f:if condition="{job.contractType} == 0">
<f:translate key="tx_jobfair_domain_model_job.contract_type.0" />
</f:if>
I'll change the target at de.locallang.xlf
<trans-unit id="tx_jobfair_domain_model_job.contract_type">
<source>Contract Type</source>
<target>Here's my german translation!!!</target>
</trans-unit>
But it isn't working!?
How can I translate or rename backend (flexform)labels for my ext.? Isn't the de.locallang.xlf the right file?
Thanks for your help.
p.s. I cleared any cache in TYPO3 .. nothing happened.
Here is my filesystem
I use it the same way for my FLUIDTEMPLATE
Template and language handling are independent components in TYPO3. Therefore the template files you overwrite the original with cannot "know" that you copied the language files somewhere else. You have several options.
Just for the record, overriding labels for the frontend can be done comfortably using TypoScript:
plugin.tx_yourext._LOCAL_LANG.[languageKey] {
labelKey = New label text
}
(The default language has "default" als languageKey.)
In the backend, you can override TCA and FlexForm labels using Page TSConfig:
# TCA
TCEFORM.tt_content.layout.label = New label
# FlexForm field
TCEFORM.tt_content.pi_flexform.[ext_key].[sheet_key].[field_key].label = New label
# Example for Powermail
TCEFORM.tt_content.pi_flexform.powermail_pi1 {
main {
settings\.flexform\.main\.optin.label = Require opt-in for mails
}
}
Please mind the backslashes in the Powermail example. The according field is called settings.flexform.main.optin. Since dots are normally "path separators", they must be escaped to make it work.
Besides from this configuration way, there's a completely different approach. You can override whole translation files:
# Override XLF for default language
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['path/to/originalTranslationFile.xlf'][]
= 'path/to/otherTranslationFile.xlf';
# Override XLF for French language
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['fr']
['path/to/originalTranslationFile.xlf'][] = 'other/path/to/fr.otherTranslationFile.xlf';
More information on this topic can be found here.
Perfect. Lorenz, thank you very much for your detailed explanation. Now I understand it and 'I'll see the bigger picture' ...
I just need the Backend-Translation in that project, like:
TCEFORM.tx_jobfair_domain_model_job {
## disable flexform/tca fields
salary.disabled = 1
discipline.disabled = 1
education.disabled = 1
# rename or translate
job_title.label = Stelle
employer.label = Arbeitgeber
employer_description.label = Arbeitgeberbeschreibung
}
But I also test it for the frontend view:
plugin.tx_jobfair._LOCAL_LANG.de {
tx_jobfair_domain_model_job.contract_type = Vertragsart
}
Works perfect!
Thank you very much!

Wingding issue in HTML Agility Pack

I am having a problem while using the HTML Agility Pack.
I have an html file. All I do is load that file using an HtmlDocument instance, and replace the urls of images in the document. Given below is the code used:
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.OptionFixNestedTags = true;
htmlDoc.Load(filePath);
HtmlNodeCollection images = htmlDoc.DocumentNode.SelectNodes("//img");
string source;
string imageName;
string newSource;
if (null != images && 0 < images.Count)
{
foreach (HtmlNode image in images)
{
source = image.Attributes["src"].Value;
imageName = Path.GetFileName(source);
newSource = imageUris[imageUris.IndexOf(imageName)];
if (null != newSource)
{
image.Attributes["src"].Value = newSource;
}
}
}
htmlDoc.Save(filePath);
The problem is that the Html document contains an empty check box and a check box with a 'x' created using the wingdigns font. After saving the file, the check box with 'x' in it gets changed to some weird characters like a left-pointing arrow, followed by 1 in a circle, followed by a clock and a number of A with ~ on top of it.
Similar thing happens with the empty check box.
Can someone please suggest some solution to preserve the check boxes?

Clickable Url in Twitter

i have implemented a simple twitter reader in my app. I am able to get the tweets of a
user. But, if there is a url in this tweet, i cant click on it, as its not detected as an URL.
Is there a possibility to implement this function, so that urls in the tweet are displayed
as clickable url, and then launch for example a webbrowser?
Thank you very much
I assume you are using a TextBlock to show the tweet text, correct? If so, change it to a RichTextBox and all you need to do is use Run for text and Hyperlink for the links!
Also, make sure you set the IsReadOnly property of the RichTextBox to true in order for it to work properly!
Next, parse the tweet text with a regular expression to find links, and use the Hiperlink class to create a clickable link on it, and Run on the remaining text!
Here's a sample function that will parse a tweet and build the content for a RichTextBox:
private Block ParseTweet(string tweetText)
{
var paragraph = new Paragraph();
var lastIndex = 0;
foreach (Match m in Regex.Matches(tweetText, #"(http(s)?://)?([\w-]+\.)+[\w-]+(/\S\w[\w- ;,./?%&=]\S*)?"))
{
if (m.Index > 0)
paragraph.Inlines.Add(tweetText.Substring(lastIndex, m.Index));
var hyperlink = new Hyperlink()
{
NavigateUri = new System.Uri(m.Value, System.UriKind.RelativeOrAbsolute),
TargetName = "_blank"
};
hyperlink.Inlines.Add(m.Value);
paragraph.Inlines.Add(hyperlink);
lastIndex = m.Index + m.Length;
}
if (lastIndex < tweetText.Length)
paragraph.Inlines.Add(tweetText.Substring(lastIndex));
return paragraph;
}
You should call this function like so:
var tweetText = #"Testing: http://twitter.com -> link for twitter";
MyRichTextBox.Blocks.Add(ParseTweet(tweetText));
I think it's not possible but but you can parse your text to find URL (with regex) and display a hyperlink below the text.
1) you search for URLs in the text with a regex
2) if a URL is found, you create a HyperlinkButton with this URL

newb: typo3 access uploaded images in typoscript

I'm trying to do something like in this Tutorial, a very basic gallery.
In the example of the Tut they load images from uploads/media/ like so
page.10.marks.PROJECTTHUMBNAIL = IMG_RESOURCE
page.10.marks.PROJECTTHUMBNAIL {
stdWrap.wrap = <img src="|" />
file {
import = uploads/media/
import.data = levelmedia: -1,slide
import.listNum = 0
}
}
but now I want to load pictures that have been uploaded in an image-cObject.
This is an embarrassing question but I've been trying to figure this out for two days and I can't seem to get it right -.- I'm sure there are lots of answers out there... I just don't know the magic words to put into google to FIND them T-T
I tried very basic stuff like just doing the same as above but with a different path, I rummaged through the TSRef of IMAGE and IMG_RESOURCE, tried fiddling with CONTENT, and tried to adapt the tt_content.image.20 = USER (?? O.o) description in the typoscript object-browser... but all to no avail, as I know so little what I'm doing -.-
Any nudge in the right direction would be greatly appreciated!
You have to load the content elements using the CONTENT cObject and set how the content shall be rendered. This will load Image content elements on the given page regardless of what column they are in:
page.10.marks.PROJECTTHUMBNAIL = CONTENT
page.10.marks.PROJECTTHUMBNAIL {
table = tt_content
select {
where = CType = 'image' AND image != ''
orderBy = sorting ASC
}
renderObj = IMAGE
renderObj {
file {
import = uploads/pics/
import.field = image
import.listNum = 0
}
}
}
NOTE: The renderObj is just my example and it renders only the first image of the Image element. You can set the rendering as you please, e.g. set the file to be GIFBUILDER which would allow you to resize the image. You can also tweak the select to load content elements with more refined conditions.

Resources