Search for string part per TypoScript

To search a string part (needle) in string (haystack), you can easily use the PHP strpos function. But this function doesn’t exist in TypoScript.

The following TypoScript return true if the needle is found in the haystack. This can be used in an if condition.

The above COA will return true if http is found in the header_link field. I used this to add ATagParams for external link, in assumption that link with http(s) is an external link.

Adding javascript: in href using TYPO3 RTE

The link wizard is a great tool for normal TYPO3 user to add link (internal, external, or email link). But what if a javascript function needs to be triggered manually by clicking a link? you can make an onClick event listener to achieve this. But in RTE you can also adds javascript:someFunction(); as href parameter.

To do this, switch to text mode in RTE by clicking the <> button and put your link manually. Following parameters need to be added manually:

so should the link looks like

Fail downloading file on Android

How hard is it, to write a PHP script to allow user to download a file? really easy, one would say. Just send the appropriate HTTP header and echo the file content.

Basically that’s all I need to force download per PHP. But somehow Android stock browser (Chrome) only downloads and creates a 0 kB file. Other browser (tested with Firefox on Android) saves the file correctly.

What does happen here?

Continue reading Fail downloading file on Android

Extbase and RealURL

another day, another problem. Extbase is becoming main framework for TYPO3 extension, because it’s really easy to create a frontend plugin to show (listing or detail view) of a records. Since it’s MVC framework, Extbase create a complex URL for each record.


http://domain.tld/pageName/?tx_extension_plugin[action]=show&tx_extension_plugin[controller]=controllerName&tx_extension_pluginName[param]=9

how to short this?

Continue reading Extbase and RealURL

Standalone view in extbase

Usually a view in extbase is always called from a controller.  but what if, an action in your controller is called as an eID and only parts of the template needs to be rendered? Partial is an option, but I have a code snippet, which uses the

class.

Continue reading Standalone view in extbase

add class to link in RTE

It’s might be a simple problem, but yet it’s really hard to find the correct solution. Although the solution is a simple one.

Using any of the CSS frameworks out there, you can easily create a button, even from a link, just by adding a class. The problem is, how you can put this class in RTE, so that the editor can easily choose which button class should be used.

Continue reading add class to link in RTE

redirect URL to lowercase

Using the realurl extension TYPO3 generate human-readable URL. If the visitor visits the page using uppercase of the URL, TYPO3 can generate the page (HTTP 200). if a search bot (Google) found this URL and indexed it, Google will declare the page as “double content” and punishes your page rank. How do we deal with this? Continue reading redirect URL to lowercase

[TYPO3] Redirect to last page

Problem of the week:

you have a password protected pages on your TYPO3 site. If you spread the URL of the pages and other user will be shown the login page, if they call the URL. Problem will be, after logging in, the user is not redirected to the last page, which they call.

The felogin extension of TYPO3 supports 6 type of redirect after login:

  1. defined by usergroup record
  2. defined by user record
  3. TypoScript or Flexform of the felogin extension
  4. GET/POST-Parameter
  5. Referer
  6. Domain entries

The solution is the “referer” redirection. The question is how. This is where we use the fabulous TypoScript.

This TypoScript creates a redirect per meta tag (see wrap), but to which URL. The magic happens in the typolink function. xxx is your login page. The GET parameter “referer” will have the value of the last page, which the user visited.

The magic does not end here. You have to set to “referer” redirect in the flexform of the felogin extension.

felogin

so that’s all.. hope this could be help.

Cheers

 

 

Wrapping image based on width… pure TypoScript

following issue: images should be wrapped with various class parameter (or div, or whatever) based on its width. And it should be solved only per TypoScript…

hmmm… quite a difficult one, don’t you think? well, you know what… I solved it… :D

Continue reading Wrapping image based on width… pure TypoScript

Rewrite robots.txt

Your CMS (read: TYPO3) can handle multiple subdomain in one installation. Problem: you can only put one robots.txt in the htdocs. The following rewrite rule will solve the problemby rewriting robots.txt to robots_(subdomain).txt

it will do following rewrite:

  • www.domain.tld/robots.txt will load robots_www.txt
  • sub1.domain.tld/robots.txt will load robots_sub1.txt, if it’s not exist, then robots_def.txt will be loaded