Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend RenderNames classes for indicating editors with a constant string #25

Open
zuphilip opened this issue Aug 19, 2017 · 3 comments
Open

Comments

@zuphilip
Copy link
Member

I would like to extend the classes Classes\ViewHelpersRenderNames*.php such that they have a second parameter which will add "(Hrsg.)" at the end of the output string, which than can be called from the Resources\Private\Partials\Frontend*.html. Moreover, it would be nice to have this as a language-dependent term, i.e. "(Eds.)" for English and "(Hrsg.)" for German.

I tried a little but without any success...

Probably a good idea to do this together with #24 or afterwards.

@sebeka
Copy link
Collaborator

sebeka commented Aug 22, 2017

Hi Philip,

not sure if it helps you, but in RenderNamesWithAndViewHelper.php is used the translation stuff for example:
$output .= " " . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('and', 'publist4ubma2') . " ";

to use this, you have to add the english translation to Resources/Private/Language/locallang.xlf and the german to Configuration/TypoScript/setup.txt

Not sure if this is the best way in typo3, but tx_news extension did it like this.

Sebastian

@zuphilip
Copy link
Member Author

I had problems by just creating and using a second parameter for such a class. I didn't yet touch the localization...

@sebeka
Copy link
Collaborator

sebeka commented Aug 23, 2017

OK, not sure If I tried this before, but I would expect something like:

    /**
     * Render the viewhelper
     *
     * @param string $first parameter
     * @param string $second parameter
     * @return string with output
     */
    public function render($first, $second)
    { ... }

Run this with something like:
<m:nameOfViewHelper first="{value.first}" second="{value.second}"/>

Check here:
https://docs.typo3.org/typo3cms/ExtbaseFluidBook/8-Fluid/8-developing-a-custom-viewhelper.html

"If you forget to specify the type of a parameter, an error message will be displayed. Check at all times that the PHPDoc block is complete and syntactical correct. For example, if you forget the @ in front of the param, the type of the parameter is not identified."

On the other hand, you should be able to inject some other class from your project - Maybe it is possible to access some global variables or the databases, for getting extra/arguments.
-> But I think ViewHelpers should not become to big, otherwise they will slow down rendering

Sebastian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants