I have a site which shows a teaser (image+text) on all pages.
This should be editable from admin, so I created a small backend module (a simple form) where the admin should set the image and the text and save them in Typo3's registry db table:
This is how I save the text:
$request = $this->controllerContext->getRequest();
$arguments = $request->getArguments();
$registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( 't3lib_Registry' );
$extKey = $request->getControllerExtensionKey();
$registry->set( $extKey, 'text', $arguments['settings']['text'] );
but I don't know how to add an "Add image" link to display the file browser and get the url/id of the selected file.
Any ideas?
Thanks.
In order to have a file picker you will need to have a TCA for a FAL field. A TCA is usually connected to a table and I wouldn't know of any implementation with the registry as a "storage backend".
This means you would have to create TCEForms yourself and then intercept the saving process. This is possible but rarely used and rather complicated, see an example here:
https://git.typo3.org/Packages/TYPO3.CMS.git/blob/TYPO3_4-5:/typo3/sysext/version/ws/workspaceforms.php
(for TYPO3 4.x, for 6.x the class names have to be adjusted)
So I would suggest that you extend the table pages with a field for text and a FAL field instead of trying to write an own backend module for this purpose.
Related
I got a Google drive picker item on my web app. Looking at Google Docs I find out the it display one option tab called "Recent".
Following the documentation at https://developers.google.com/picker/docs/reference I couldn't find any reference to this tab mode, only found "Recently Picked" for files I recently picked from the picker, but I'm looking to emulate this function.
My current code is
new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.enableFeature(google.picker.Feature.SUPPORT_TEAM_DRIVES)
.setAppId(appId)
.setOAuthToken(oauthToken)
.addView(new google.picker.DocsView().setIncludeFolders(true).setOwnedByMe(true))
.addView(new google.picker.DocsView().setIncludeFolders(true).setOwnedByMe(false))
.addView(new google.picker.DocsView().setStarred(true).setLabel('Starred'))
finally after reading the documentation of Google picker and the google groups dedicated to it, I figured out that there is no preset or config for recent uploaded files and even trying to build a custom view with google.picker.view, the query field is quite limited and didn't allow the option to sort the files.
After reading the javascript code of docs.google.com for the file picker I found few variables that are accessible in the moment when you call the method .addView(). This field are:
El: is the filter type for the document type.
mc: this old the whole view configuration and fields. Example: mc.query is equivalent for the View.setQuery.
xd: this field manage the View title in the top nav tab title.
While this method is a bit hacky, is the only option I got in the meantime to replicate the "recent" view tab from google docs. Here is the code I used:
let recentView = new google.picker.DocsView();
recentView.xd = 'Recent';
recentView.mc.sortKey = 15;
let picker = new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.enableFeature(google.picker.Feature.SUPPORT_TEAM_DRIVES)
.setAppId(appId)
.setOAuthToken(oauthToken)
.addView(new google.picker.DocsView().setIncludeFolders(true).setOwnedByMe(true))
.addView(new google.picker.DocsView().setIncludeFolders(true).setOwnedByMe(false))
.addView(new google.picker.DocsView().setIncludeFolders(true).setStarred(true).setLabel('Starred'))
.addView(recentView)
.addView(new google.picker.DocsUploadView().setIncludeFolders(true))
.setDeveloperKey(developerKey)
.setCallback(onFilePickerCB)
I have a layout web part which has a "Teaser" field. The "Teaser" field uses a "media selection" form control. In this case the field is set to an image uploaded to one of the sites media libraries.
I want to render that image, so I'm trying to get the relative URL to it in the codebehind:
if (Teaser != Guid.Empty) // Teaser is {8d7fa1ab-b304-474f-9ab9-2e17e8fee84f}
{
var mediaInfo = MediaFileInfoProvider.GetMediaFileInfo(Teaser, SiteContext.CurrentSiteName);
// mediaInfo is null so the next line crashes
var libraryInfo = MediaLibraryInfoProvider.GetMediaLibraryInfo(mediaInfo.FileLibraryID);
string url = MediaFileURLProvider.GetMediaFileUrl(mediaInfo, SiteContext.CurrentSiteName, libraryInfo.LibraryFolder);
The "mediaInfo" variabe is null, so the code crashes.
How can I get a relative URL to my media file?
You cannot add the "Media selection" form control in combination with an field type Guid. Then you need to create an custom form control if you need to have only the Guid.
But an better solution is add an field with the data type "text" and in combination with the form control "media selection" then adds directly the relative URL inside the field when selecting an image from the media library.
If you also need the MediaInfo then you can get this object with the parameter "mediaFilePath", like described here : https://devnet.kentico.com/docs/8_2/api/html/M_CMS_MediaLibrary_MediaFileInfoProvider_GetMediaFileInfo_3.htm
Good luck and if you have more questions you can always ask them here on StackOverflow or on http://devnet.kentico.com/questions-answers.
If this answer helped you, please vote for my answer :-)
--
Hello!
I use TYPO3 CMS 6.2.9 and the Versatile News System (tx_news).
For my User (Editor), I'll only allow to add new news records in my specific sys-folder. Here's my pageTSconfig for the sys-folder:
### only for EDITORS usergroup 2
[usergroup = 2]
# only show "new news and news tag" for a new data record
mod.web_list {
allowedNewTables = tx_news_domain_model_news, tx_news_domain_model_tag
}
[GLOBAL]
It works.
But how can I translate the labels, for example in german: "Artikel" and "Nachrichten-Tag" in List-View for my Editor. I can't find these strings in Ext. news folder (typo3config/ext/news). In this case, I'll use tx_news not for NEWS, so it won't confuse my backend-user (editor) ;)
I#m talking about this List View:
I can translate all other labels via TCEFORM
TCEFORM.tx_news_domain_model_news.title.label.de = Überschrift
but not the labels at list view.
Thanks for your help.
These labels are configured in TCA for given table and only way to override it is changing it's value i.e. by adding this line to typo3conf/extTables.php
$TCA['tx_news_domain_model_news']['ctrl']['title'] = 'Change me...';
Problem with this is you can't do it conditionally by default, maybe this EXT will help you (as mentioned on some forum it's not maintained anymore)
http://docs.typo3.org/typo3cms/extensions/tcamanipulate/
How to find it: Every table has its TCA (required) so you can find it with editor, or using SYSTEM > Configuration module to browse currently loaded TCA.
I'm fairly new to Orchard and I'm wondering about the "best" way of building a basic list of documents with a download link?
Say the scenario is this, I want to make a list of newsletters, the news letter are in PDF format and the users should be able to download then straight from the list view.
An admin, should easily be able to add a new newsletter and it should turn up in the list.
My current train of thought is to, all through the dashboard,
create a content type "Newsletter" with a title field and a Media picker field, using the media picker field to upload the PDF file.
Then create a query, with the filter on Content type "Newsletter"
Create a projection pointing to the query
However, this only gives me a list of content items, showing their title as links back to the actual content item.
I've tried adding a layout to the query and set it to display properties instead of content. By doing that I can get a list where I can control the "output" a bit more. And I've gotten it to list the title and by doing a Rewrite and putting in the MediaPicker.Url, it also displays the URL in the list. This is all good but here I get stuck..
As the MediaPicker.URL outputs the url in the format like ~/media/default/xyz/filename.pdf, I cant just put it into a a href, it doesn't give a correct download link to the file.
Soo, question is, am I thinking and doing this totally the wrong way or am I missing something obvious? All ideas and suggestions and more then welcome.
Use or adapt the following template override in your theme:
#{
var url = Model.ContentField.Url;
}
#if(Model.ContentField.Url != null) {
if (url.StartsWith("~/")) {
url = Href(url);
}
<div class="media-picker-field attachment-pdf">
<span>download</span>
</div>
}
Modify the text as needed. This template was a Fields.MediaPicker-PDF.cshtml that was used for a media picker field named PDF.
I'm new to ModX, but I have created a Template Variable (TV) for an Image ( image-1 ) .
Then I set a default value, and assign the TV to my Home_Template, click save.
Create some simple html in that template:
<li>[*image-1*]</li>
As expected, the template variable is available on this screen. So I select the image I want to display, and save. It appears in the preview for this template screen, but not on the actual website.
Any ideas?
check your caching settings ~ probably best to turn off caching completely during development.
also try calling your snippets & variables as 'uncached' ex:
[!*image*]
this looks like evolution code, best to switch to revolution if at all possible.
-sean