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

Class parameters from Linkwizard in generated link #17

Open
frankschuessler opened this issue Feb 11, 2016 · 7 comments
Open

Class parameters from Linkwizard in generated link #17

frankschuessler opened this issue Feb 11, 2016 · 7 comments

Comments

@frankschuessler
Copy link

Hi,
it seems like after adding a link in link wizard to a resource record the chosen classes in wizard are not included in generated link.
After adding the following lines to Classes/TypolinkHandler.php line 175 this worked for me:

// readd the class to link given in RTE back to link        
if($this->linkParameters['class']){
    $typoScriptConfiguration['ATagParams'] = 'class="'.$this->linkParameters['class'].'"';
}

Maybe you could include this in the next release?

@fsuter
Copy link
Contributor

fsuter commented Feb 11, 2016

I'll take a look, thanks for reporting. I guess it's a more general issue. I'll check with all the possible parameters that can be defined in the dialog box.

@fsuter
Copy link
Contributor

fsuter commented Feb 26, 2016

I could not reproduce the error. Parameters are parsed on line 103:

$this->linkParameters = GeneralUtility::makeInstance(TypoLinkCodecService::class)->decode($linkParameters);

and reassembled on line 156:

$typoScriptConfiguration['parameter'] = GeneralUtility::makeInstance(
        TypoLinkCodecService::class
)->encode(
        $this->linkParameters
);

If the problem persists for you, could you debug these places?

@fsuter
Copy link
Contributor

fsuter commented Mar 22, 2016

Any feedback here? Does it work for you after all?

@dp-michaelhuebe
Copy link

Same problem to me.

Currently it is only working if configuration something like this:

plugin.tx_linkhandler.tt_address {

    // Do not force link generation when the record records are hidden or deleted.
    forceLink = 0

    typolink {
        parameter = 1
        forceAbsoluteUrl = 0
        useCacheHash = 0
    }
}

But it is broken if typolink parameter typoscript changed to something like this:

plugin.tx_linkhandler.tt_address {

    // Do not force link generation when the record records are hidden or deleted.
    forceLink = 0

    typolink {
        parameter.cObject = TEXT
        parameter.cObject {
            field = phone
            stdWrap.replacement {
                10 {
                    search.char = 32
                    replace =
                }
            }
            wrap = tel:|
        }
        forceAbsoluteUrl = 0
        useCacheHash = 0
    }
}

@dp-michaelhuebe
Copy link

Use hook to fix this problem:

File: myext\Classes\Hooks\TypolinkHandler.php


<?php
namespace Vendor\Myext\Hooks;
/**
 * Handler to create typolinks to arbitrary DB records.
 *
 * Based on original code by AOE and modified by a lot of people.
 */
class TypolinkHandler extends \Cobweb\Linkhandler\TypolinkHandler implements \Cobweb\Linkhandler\ProcessLinkParametersInterface {

    /**
     * Hook the generation of a typolink
     *
     * @return void
     */
    public function process($linkHandler) {

        // read the class to link given in RTE back to link
        if ($linkHandler->linkParameters['class']) {
            $linkHandler->typolinkConfiguration['ATagParams'] = 'class="' . $linkHandler->linkParameters['class'] . '"';
        }

        // read the title to link given in RTE back to link
        if ($linkHandler->linkParameters['title']) {
            $linkHandler->typolinkConfiguration['title'] = $linkHandler->linkParameters['title'];
        }

    }

}

Enable the hook in your ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkhandler']['generateLink']['myext'] 
= 'Vendor\\Myext\\Hooks\\TypolinkHandler';

@pduersteler
Copy link

Same problem here. Thanks for the hook!

@Hawkeye1909
Copy link

Same issue here. The problem is that the class-part in $linkParameters doesn't include the class-attribute (example from bodytext-field <link record:tx_ttnews:tt_news:123 _blank Class>Text</link>). So it has to be added as it's done in the aforementioned and working solutions.

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

5 participants