How to check if file (image) exists in TypoScript? - typo3

I'd like to check if a certain file (image) actually exists and make the output dependent on the result. How to do that in TypoScript?

Probably the fastest solution will be using userFunc condition as described in the docs.
The sample is self-explanatory, so there's no need to put it here.

Because the link to the docs is outdated, and I came here via a search engine, I would like to link to a possible solution. Here we go: Typoscript - Link a file only if it exists using URL

Related

TYPO3 store Extension-Builder image via FormFields.html

Images currently are not handled by the extension-builder.
I am looking for a kind of "f:form", where I can store the image file name with the submit function, inside FormFields.html.
If I use f:form.textfield I get in trouble with format.
I already tries
...originalResource.url and
...originalResource.name
I am using TYPO3 7.6.14
How I have to handle this task?
Implementing a File Upload with FAL in Extbase is not that easy. Here is an example extension in Github - mostly I do it like there: https://github.com/helhum/upload_example
But be warned: It's not for beginners...

Get HTML Equivalent of Google Doc contents

I am trying to get the HTML for a Google Doc's contents. The methods I have found all seem to use deprecated items. I ultimately want to use the Doc as a template for an email. I have everything working except getting the HTML version of the text. Yes, I want the full HTML version including tables, images, and anything else I can place in the Doc.
Is there any way to get this?
Regards,
Karl S
I believe the following method works:
Open up the Google Doc you want to work with
Click File-->Publish to the web
Click Link and then Publish
Copy the link into another tab
View the source for the page and copy everything inside and including <div id="contents">
This should be the complete HTML for that document. I just verified that it works with a document of mine. Let me know if it doesn't.

How do I embed a single file from a GitHub gist with the new gist interface?

The new GitHub Gist interface has one embed snippet for the entire gist which embeds all files in the gist. The old interface had embed code for each file in the gist. Anyone know if there's a trick to embed a single file?
Take the gist URL from the left-hand side and after the .js add a query string like ?file=myFile.blah, e.g.
<script src="https://gist.github.com/4505639.js?file=macroBuild.scala" type="text/javascript"></script>
Medium
For those who want to use it on the medium, Medium does not support and does not query parameters in the URL when you add it after the paste of the URL. So just follow these 4 steps IN THE ORDER.
So:
⚠️ Order matters!
Copy the (multi-file) gist path. e.g.:
https://gist.github.com/MojtabaHs/91e34fd0e987fe7ce801936dc6ece0e8
Paste it somewhere else than the Medium article that not preserves the rich data of the text. Like an online textbox for example:
⚠️ Do not hit search or return button
Append the query param for the file to the URL. e.g:
https://gist.github.com/MojtabaHs/91e34fd0e987fe7ce801936dc6ece0e8?file=Interface.swift
Note that ?file=Interface.swift at the end of the URL, right?
Copy and paste it in the article and see the magic 🔮
An article using this method:
Implement Custom Activity Indicator With The SwiftUI
The MOST Important note that MUST be considered:
⚠️ Note that you MUST copy an unformatted plain text in the medium and MUST NOT edit the URL after pasting it in the Medium! You can copy the link in an online textbox like google.com and after appending the query, copy it back and paste it in the Medium.
GitHub provides this same information here on their site. As others have said the official way is to attach ?file=name-of-file.ext to the end of the embed code's URL in order to only embed the file called name-of-file.ext (you can of course change the name to whatever the name of your file is). For example, if I wanted to embed the getGitContents.js file from the Gist at https://gist.github.com/westc/afac9258389fdfd2fdaf134ffaa0e923 I can use the following:
<script src="https://gist.github.com/westc/afac9258389fdfd2fdaf134ffaa0e923.js?file=getGitContents.js"></script>
In addition there is this YourJS blog post about this which allows you to enter your user name and see the embed codes for all of your gists and the underlying individual files.
Just for other people reference that might be looking into this.
If you are using Wordpress you may achieve this with the plugin oEmbed-gist and shortcode style:
[gist id="your-gist-id-here" file="your-file-name.js"].

Moving site form typo3 to concrete5

Is there any other way than copy paste text, to move content from typo3 to concrete5?
Best Regards
Mats Krüger
Maybe, if your typo3 page is simple/big enough, it's possible/worth to write a php script that gets data from typo3's database, manipulates and writes into concrete5's. Database logic seems to be quite different though, so it can be tricky.
Without any information about the structure you can import into concrete5 it is difficult to answer. But there are some general possibilities to export data from TYPO3.
There is an Extension l10nmgr which is desined to output TYPO3 content for translation processes. Perhaps you can use the XML and transform it?
You could just write an TypoScript Template which creates an XML File with tags you need. It should be easy to export the build in content elements with that.
Or just have a look at the database and write an connector as kraabus mentioned.

How can I get all HTML pages from a website subfolder with Perl?

Can you point me on an idea of how to get all the HTML files in a subfolder and all the folders in it of a website?
For example:
www.K.com/goo
I want all the HTML files that are in: www.K.com/goo/1.html, ......n.html
Also, if there are subfolders so I want to get also them: www.K.com/goo/foo/1.html...n.html
Assuming you don't have access to the server's filesystem, then unless each directory has an index of the files it contains, you can't be guaranteed to achieve this.
The normal way would be to use a web crawler, and hope that all the files you want are linked to from pages you find.
Look at lwp-mirror and follow its lead.
I would suggest using the wget program to download the website rather than perl, it's not that well suited to the problem.
There are also a number of useful modules on CPAN which will be named things like "Spider" or "Crawler". But ishnid is right. They will only find files which are linked from somewhere on the site. They won't find every file that's on the file system.
You can also use curl to get all the files from a website folder.
Look at this man page and go to the section -o/--output which gives u a good idead about that.
I have used this a couple of times.
Read perldoc File::Find, then use File::Find.