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

Switch from marker based to fluid templates #62

Open
TheJotob opened this issue Sep 24, 2019 · 6 comments
Open

Switch from marker based to fluid templates #62

TheJotob opened this issue Sep 24, 2019 · 6 comments
Assignees

Comments

@TheJotob
Copy link

Hi,
is there a plan for the future to switch from marker based to fluid based templating?
The minimum supported TYPO3 Version is 8.7 so this should not break any backwards compatibility. Maybe this should be in another major version of mksearch though.

@RocKordier
Copy link
Contributor

Hey @TheJotob
I'm not very into this topic but it should be possible to change the viewClassName to use FluidTemplates

ext/Configuration/TypoScript/Extensions/Mksearch.setup.typoscript

plugin.tx_mksearch {
	searchsolrTemplate = {$path.template.ext}Mksearch/solrSearch.html.twig
	searchsolr {
                viewClassName = Sys25\RnBase\Fluid\View\Action
	}
}

It's also possible use Twig for template rendering. But you have to install another bundle:
https://github.com/DMKEBUSINESSGMBH/typo3-t3twig

plugin.tx_mksearch {
	searchsolrTemplate = {$path.template.ext}Mksearch/solrSearch.html.twig
	searchsolr {
		viewClassName = DMK\T3twig\View\RnBaseView
	}
}

If you have some future questions @hannesbochmann and @rengaw83 could answer.

Eric

@rengaw83
Copy link
Member

hi @TheJotob,

Eric has already explained it well, thanks eric ;).

At the moment there is no build in fluid template, but we support fluid views.
We will consider to ship mksearch with a standard fluid template in the future.

Here are some detailed information about the fluid views.
mksearch uses rnbase as base library.
the template engine can be changed by typoscript in whatever you want.
rn_base comes with a fluid view you can configure like this:

plugin.tx_mksearch {
    view {
        templateRootPaths.0 = EXT:my_extension/Resources/Private/Ext/Mksearch/Templates/
        partialRootPaths.0 = EXT:my_extension/Resources/Private/Ext/Mksearch/Partials/
        layoutRootPaths.0 = EXT:my_extension/Resources/Private/Ext/Mksearch/Layouts/
    }
    searchsolrTemplate = EXT:my_extension/Resources/Private/Ext/Mksearch/Templates/Search.html
    searchsolr {
        viewClassName = Sys25\RnBase\Fluid\View\Action
    }
}

There are some helpful viewhelpers too. have a look to the docs.

example of Search.html:

<html
    xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
    xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
    xmlns:rn="http://typo3.org/ns/Sys25/RnBase/ViewHelpe"
    data-namespace-typo3-fluid="true"
>

{namespace v=FluidTYPO3\Vhs\ViewHelpers}
{namespace rn=Sys25\RnBase\Fluid\ViewHelper}

<form method="GET" id="sitesearch">
    <fieldset class="term">
        <div>
            <input
                type="text"
                name="mksearch[term]"
                value="{term}"
                id="mksearch_term"
                class="text"
            />
        </div>
    </fieldset>
    <fieldset>
        <input
            type="hidden"
            name="mksearch[submit]"
            value="{rn:translate(key : 'label_search_submit')}"
            title="{rn:translate(key : 'label_search_submit')}"
            class="text"
        />
        <input
            type="submit"
            name="mksearch[submit]"
            value="{rn:translate(key : 'label_search_submit')}"
            class="submit"
        />
    </fieldset>
</form>

<f:if condition="{result.numFound} > 0">
    <f:then>
        <ul>
            <f:for each="{result.items}" as="item" iteration="iterator">
                <li>
                    <h2>{record.title}</h2>
                    <p>{record.abstract]</p>
                    <f:switch expression="{item.content_ident_s}">
                        <f:case value="core.tt_content">
                            {f:uri.page(pageUid: item.pid, section: item.uid)}
                        </f:case>
                    </f:switch>

                </li>
            </f:for>
        </ul>
        <f:render partial="PageBrowser" arguments="{_all}" />
    </f:then>
</f:if>

I hope that helps at the moment.

best regards

@dzschille
Copy link

Hello @rengaw83, i tried you suggestion with Elasticsearch and get an error from rn_base. My config is

plugin.tx_mksearch {
    view {
        templateRootPaths.0 = EXT:my_extension/Resources/Private/ext/mksearch/Templates/
        partialRootPaths.0 =  EXT:my_extension/Resources/Private/ext/mksearch/Partials/
        layoutRootPaths.0 =   EXT:my_extension/Resources/Private/ext/mksearch/Layouts/
    }

    elasticsearchTemplate = EXT:my_extension/Resources/Private/ext/mksearch/Templates/Search.html
    elasticsearch {
        viewClassName = Sys25\RnBase\Fluid\View\Action
    }
}

And when i open the page with the search plugin i get this error:

"Exception": {
   "message": "The extension key yould not be resolved. Please check your typoscript configuration.",
   "code": 0,
   "file": "/var/www/public/typo3conf/ext/rn_base/Classes/Fluid/View/Action.php",
   "line": 51,
   "trace": "#0 /var/www/public/typo3conf/ext/rn_base/action/class.tx_rnbase_action_BaseIOC.php(107): Sys25\\RnBase\\Fluid\\View\\Action-&gt;render('elasticsearch', Object(Tx_Rnbase_Configuration_Processor))\n#1 /var/www/public/typo3conf/ext/rn_base/class.tx_rnbase_controller.php(262): tx_rnbase_action_BaseIOC-&gt;execute(Object(Sys25\\RnBase\\Frontend\\Request\\Parameters), Object(Tx_Rnbase_Configuration_Processor))\n#2 /var/www/public/typo3conf/ext/rn_base/class.tx_rnbase_controller.php(233): tx_rnbase_controller-&gt;doAction('tx_mksearch_act...', Object(Sys25\\RnBase\\Frontend\\Request\\Parameters), Object(Tx_Rnbase_Configuration_Processor))\n#3 [internal function]: tx_rnbase_controller-&gt;main('', Array)\n#4 /var/www/public/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php(5969): call_user_func_array(Array, Array)\n#5 /var/www/public/typo3/sysext/frontend/Classes/ContentObject/UserContentObject.php(41): TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer-&gt;callUserFunction('tx_rnbase_contr...', Array, '')\n#6 /var/www/public/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php(815): TYPO3\\CMS\\Frontend\\ContentObject\\UserContentObject-&gt;render(Array)\n#7 /var/www/public/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php(731): TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer-&gt;render(Object(TYPO3\\CMS\\Frontend\\ContentObject\\UserContentObject), Array)\n#8 /var/www/public/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php(3853): TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer-&gt;cObjGetSingle('USER', Array)\n#9 /var/www/public/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php(3814): TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController-&gt;INTincScript_process(Array)\n#10 /var/www/public/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php(3781): TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController-&gt;recursivelyReplaceIntPlaceholdersInContent()\n#11 /var/www/public/typo3/sysext/frontend/Classes/Http/RequestHandler.php(187): TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController-&gt;INTincScript()\n#12 /var/www/public/typo3/sysext/frontend/Classes/Middleware/OutputCompression.php(46): TYPO3\\CMS\\Frontend\\Http\\RequestHandler-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#13 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\OutputCompression-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(TYPO3\\CMS\\Frontend\\Http\\RequestHandler))\n#14 /var/www/public/typo3/sysext/adminpanel/Classes/Middleware/AdminPanelDataPersister.php(44): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#15 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Adminpanel\\Middleware\\AdminPanelDataPersister-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#16 /var/www/public/typo3/sysext/adminpanel/Classes/Middleware/AdminPanelRenderer.php(46): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#17 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Adminpanel\\Middleware\\AdminPanelRenderer-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#18 /var/www/public/typo3/sysext/frontend/Classes/Middleware/ContentLengthResponseHeader.php(45): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#19 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\ContentLengthResponseHeader-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#20 /var/www/public/typo3/sysext/frontend/Classes/Middleware/ShortcutAndMountPointRedirect.php(65): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#21 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\ShortcutAndMountPointRedirect-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#22 /var/www/public/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php(118): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#23 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\PrepareTypoScriptFrontendRendering-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#24 /var/www/public/typo3/sysext/frontend/Classes/Middleware/PageArgumentValidator.php(99): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#25 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\PageArgumentValidator-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#26 /var/www/public/typo3/sysext/frontend/Classes/Middleware/MaintenanceMode.php(53): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#27 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\MaintenanceMode-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#28 /var/www/public/typo3/sysext/frontend/Classes/Middleware/PageResolver.php(171): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#29 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\PageResolver-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#30 /var/www/public/typo3/sysext/frontend/Classes/Middleware/PreviewSimulator.php(62): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#31 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\PreviewSimulator-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#32 /var/www/public/typo3/sysext/redirects/Classes/Http/Middleware/RedirectHandler.php(70): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#33 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Redirects\\Http\\Middleware\\RedirectHandler-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#34 /var/www/public/typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php(62): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#35 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\StaticRouteResolver-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#36 /var/www/public/typo3/sysext/frontend/Classes/Middleware/SiteBaseRedirectResolver.php(86): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#37 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\SiteBaseRedirectResolver-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#38 /var/www/public/typo3/sysext/adminpanel/Classes/Middleware/AdminPanelInitiator.php(58): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#39 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Adminpanel\\Middleware\\AdminPanelInitiator-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#40 /var/www/public/typo3/sysext/frontend/Classes/Middleware/SiteResolver.php(68): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#41 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\SiteResolver-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#42 /var/www/public/typo3/sysext/adminpanel/Classes/Middleware/SqlLogging.php(49): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#43 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Adminpanel\\Middleware\\SqlLogging-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#44 /var/www/public/typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php(95): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#45 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\BackendUserAuthenticator-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#46 /var/www/public/typo3/sysext/frontend/Classes/Middleware/FrontendUserAuthenticator.php(79): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#47 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\FrontendUserAuthenticator-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#48 /var/www/public/typo3/sysext/frontend/Classes/Middleware/TypoScriptFrontendInitialization.php(90): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#49 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\TypoScriptFrontendInitialization-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#50 /var/www/public/typo3/sysext/frontend/Classes/Middleware/EidHandler.php(50): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#51 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\EidHandler-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#52 /var/www/public/typo3/sysext/frontend/Classes/Middleware/PreprocessRequestHook.php(57): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#53 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\PreprocessRequestHook-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#54 /var/www/public/typo3/sysext/core/Classes/Middleware/NormalizedParamsAttribute.php(58): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#55 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Core\\Middleware\\NormalizedParamsAttribute-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#56 /var/www/public/typo3/sysext/frontend/Classes/Middleware/TimeTrackerInitialization.php(49): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#57 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(138): TYPO3\\CMS\\Frontend\\Middleware\\TimeTrackerInitialization-&gt;process(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest), Object(class@anonymous))\n#58 /var/www/public/typo3/sysext/core/Classes/Http/MiddlewareDispatcher.php(67): class@anonymous-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#59 /var/www/public/typo3/sysext/core/Classes/Http/AbstractApplication.php(108): TYPO3\\CMS\\Core\\Http\\MiddlewareDispatcher-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#60 /var/www/public/typo3/sysext/frontend/Classes/Http/Application.php(69): TYPO3\\CMS\\Core\\Http\\AbstractApplication-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#61 /var/www/public/typo3/sysext/core/Classes/Http/AbstractApplication.php(120): TYPO3\\CMS\\Frontend\\Http\\Application-&gt;handle(Object(TYPO3\\CMS\\Core\\Http\\ServerRequest))\n#62 /var/www/public/index.php(24): TYPO3\\CMS\\Core\\Http\\AbstractApplication-&gt;run()\n#63 /var/www/public/index.php(25): {closure}()\n#64 {main}"
 },

What have i done wrong?

@rengaw83
Copy link
Member

Looks like the extension key config that is required by the rnbase fluid view is missing.
Can you try to add the following typoscript:

plugin.tx_mksearch.extensionKey = mksearch

@dzschille
Copy link

Great, thank! That was the missing part.

@dzschille
Copy link

If someone gets this Message (found with MK Logger):
"Classname contains invalid characters or has invalid format: Sys25\\RnBase\\Fluid\\View\\Action".

Change to above mentioned viewClassName = Sys25\RnBase\Fluid\View\Action
to viewClassName = Sys25\RnBase\ExtBaseFluid\View\Action.

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