Code Monkey home page Code Monkey logo

Comments (8)

NamelessCoder avatar NamelessCoder commented on July 23, 2024

Hi Heiko,

Sorry for the delay in responding.

This sounds like an acceptable idea but I have a few concerns:

  • At the time when the page TS config is loaded, we'll only have the pageUid in some - not all - cases.
  • The ideal UID to use in the file name would be the PID of the closest TS template which applies to the current page (because TS is where you add the FCEs), but because of the time at which the page TS config is loaded, the usual DB-methods etc. are not all available so we can't resolve these PID/UID values when loading page TS config.

I had another idea which might result in a lot less config files but would still work. But I haven't investigated it more closely and that would be required. Maybe you want to give it a shot? :)

If it is possible to add conditions in the page TSconfig, we can analyze every TS template when generating the page TS config file and create blocks: one block of TSconfig per TS template and then use conditions to check which block to use at any given time, depending on how the rootline is configured with ordinary TS. EDIT: we might not even need that many blocks if it was possible to check if the FCE configurations are identical and somehow compound the PID values to which each block applies?

Do you know if it is possible to add such a TS condition? This is the linchpin on which it all hangs... in human terms the condition would do something like "if page with uid = 123 is in my rootline" or perhaps "if a page with uid IN 123,1,2,3 is in my rootline". Maybe a userFunc is needed...?

Also, when analysing the TS templates and building the page TS config, we would need to sort pages so that the PIDs which sit in the deepest branches get considered first - that will make sure that only the closest matching PID is returned, given the condition described above.

Cheers,
Claus

from flux.

NamelessCoder avatar NamelessCoder commented on July 23, 2024

On hold, needs followup investigation as described.

from flux.

stefanisak avatar stefanisak commented on July 23, 2024

Hi Claus,

I don't know if I really understand what you guys are talking about, but it seems I got similar problems. So I give it a try, maybe we can solve that. There's a condition called PIDinRootline. As far as I can see, the file .FED_CONTENT is written on cache clear command. Probably we'll never get the pageUid on that event. The only way to render a working config I can think of, is to just grab all sys_templates and write configs in different blocks prepended by a PIDinRootline condition with respective pageUids.

The result would be a .FED_CONTENT file that looks something like:

[PIDinRootline = 1]
  mod.wizards.newContent[...]               
[GLOBAL]

[PIDinRootline = 29]
  mod.wizards.newContent[...]               
[GLOBAL]

For testing purposes I quickly hacked the following writeCachedConfigurationIfMissing():

diff --git a/Classes/Service/ConfigurationService.php b/Classes/Service/ConfigurationService.php
index 3333441..e364458 100644
--- a/Classes/Service/ConfigurationService.php
+++ b/Classes/Service/ConfigurationService.php
@@ -73,37 +73,45 @@ class Tx_Fluidcontent_Service_ConfigurationService extends Tx_Flux_Service_Confi


    /**
+    * TODO: If that's what it's all about, proof me on error, refactor me, make me reliable and performant
+    *
     * @return void
     */
    public function writeCachedConfigurationIfMissing() {
        if (TRUE === file_exists(FLUIDCONTENT_TEMPFILE)) {
            return;
        }
-       $pageUid = intval(t3lib_div::_GP('id'));
-       if ($pageUid < 1) {
-           $firstPageWithRootTemplate = array_shift($GLOBALS['TYPO3_DB']->exec_SELECTgetRows('pid', 'sys_template t', 't.root = 1 AND deleted = 0 AND hidden = 0  AND starttime<=' . $GLOBALS['SIM_ACCESS_TIME'] . ' AND (endtime=0 OR endtime>' . $GLOBALS['SIM_ACCESS_TIME'] . ')'));
-           if (TRUE === is_array($firstPageWithRootTemplate)) {
-               $pageUid = $firstPageWithRootTemplate['pid'];
-           } else {
-               return FALSE;
+
+       $rootTemplates = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pid', 'sys_template', 'deleted = 0 AND hidden = 0');
+
+       $pageTsConfig = "";
+       while($rootTemplate = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($rootTemplates)) {
+           $pageUid = $rootTemplate['pid'];
+
+           /** @var t3lib_tsparser_ext $template */
+           $template = t3lib_div::makeInstance('t3lib_tsparser_ext');
+           $template->tt_track = 0;
+           $template->init();
+
+           /** @var t3lib_pageSelect $sys_page */
+           $sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
+           $rootLine = $sys_page->getRootLine($pageUid);
+           $template->runThroughTemplates($rootLine);
+           $template->generateConfig();
+           $allTemplatePaths = $template->setup['plugin.']['tx_fed.']['fce.'];
+           $allTemplatePaths = Tx_Flux_Utility_Path::translatePath($allTemplatePaths);
+           $wizardTabs = $this->buildAllWizardTabGroups($allTemplatePaths);
+           $tmpPageTsConfig = $this->buildAllWizardTabsPageTsConfig($wizardTabs);
+
+           if (!empty($tmpPageTsConfig)) {
+               $pageTsConfig .= <<<EOT
+[PIDinRootline = $pageUid]
+   $tmpPageTsConfig
+[GLOBAL]
+
+EOT;
            }
        }
-       /** @var t3lib_tsparser_ext $template */
-       $template = t3lib_div::makeInstance('t3lib_tsparser_ext');
-       $template->tt_track = 0;
-       $template->init();
-       /** @var t3lib_pageSelect $sys_page */
-       $sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
-       $rootLine = $sys_page->getRootLine($pageUid);
-       $template->runThroughTemplates($rootLine);
-       $template->generateConfig();
-       $allTemplatePaths = $template->setup['plugin.']['tx_fed.']['fce.'];
-       $allTemplatePaths = Tx_Flux_Utility_Path::translatePath($allTemplatePaths);
-       if (is_array($allTemplatePaths) === FALSE) {
-           return FALSE;
-       }
-       $wizardTabs = $this->buildAllWizardTabGroups($allTemplatePaths);
-       $pageTsConfig = $this->buildAllWizardTabsPageTsConfig($wizardTabs);
        t3lib_div::writeFile(FLUIDCONTENT_TEMPFILE, $pageTsConfig);
    }

Is that helpful or am I getting it wrong? Please let me know about it and also if you see any drawbacks. If that's a started I could go and refactor the crappy test code and create a pull request.

Cheers,
Stefan

from flux.

stefanisak avatar stefanisak commented on July 23, 2024

Needless to say, this is of course about the fluidcontent extension and not about flux.

from flux.

NamelessCoder avatar NamelessCoder commented on July 23, 2024

Hi Stefan,

What a coincidence - I am sitting here right now using this file for another purpose and analysing exactly the code in question. PIDinRootline seems to be the last piece of the puzzle that was missing and yes, your solution is certainly in the right direction! I have a hunch this might even solve a problem that's over two years old now so by all means go ahead ;)

Cheers,
Claus

EDIT:

Needless to say, this is of course about the fluidcontent extension and not about flux.

Absolutely, you're right. I hadn't even spotted that; I read from a global list so it's not very visible which issue tracker it's in. Too bad Github doesn't have a way to move issues, but we'll manage.

from flux.

NamelessCoder avatar NamelessCoder commented on July 23, 2024

Another thought: the current behaviour should be added as the default [GLOBAL], then followed by PID-specific sets.

from flux.

NamelessCoder avatar NamelessCoder commented on July 23, 2024

Hi Stefan @stefanisak - any news about this one? Very interested in getting this multi-root support implemented! Let me know if you need my assistance. I'd be happy to take over (your example code looks like a useful starting point).

Cheers,
Claus

from flux.

NamelessCoder avatar NamelessCoder commented on July 23, 2024

Hi Stefan @stefanisak - and others,

I grabbed the code from the example and improved on it and the result is that the full root line is now taken into consideration when building the lists of available content elements.

Cheers,
Claus

from flux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.