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

Feature: Minimal Site Package ? #19

Open
susannemoog opened this issue Jan 18, 2022 · 1 comment
Open

Feature: Minimal Site Package ? #19

susannemoog opened this issue Jan 18, 2022 · 1 comment

Comments

@susannemoog
Copy link
Contributor

susannemoog commented Jan 18, 2022

While the sitepackagebuilder provides a web GUI and enables us to download "fat" site packages with many many things preconfigured, I'm missing the slightly more nerdy way: create a slim sitepackage via CLI. Maybe this is something "make" could provide. What would I consider slim? Mainly what the official tutorial about the site package creates, just going to add my overview of that to this issue for consideration:

mkdir site_package
cd site_package

mkdir -p Resources/Private/Layouts/Page
mkdir -p Resources/Private/Templates/Page
mkdir -p Resources/Private/Partials/Page/Navigation
mkdir -p Resources/Private/Language
mkdir -p Resources/Public/Css
mkdir -p Resources/Public/Images
mkdir -p Resources/Public/JavaScript
mkdir -p Configuration/TypoScript/Setup/
mkdir -p Configuration/TsConfig/Page/
mkdir -p Configuration/TsConfig/Page/PageLayout/
mkdir -p Configuration/TCA/Overrides/

touch Resources/Public/Css/app.css
touch Resources/Private/Layouts/Page/Default.html
touch Resources/Private/Templates/Page/Default.html
touch Resources/Private/Partials/Page/Navigation/MainNavigation.html
touch Configuration/TypoScript/constants.typoscript
touch Configuration/TypoScript/setup.typoscript
touch Configuration/TCA/Overrides/sys_template.php
touch Configuration/TsConfig/Page/Page.tsconfig
touch Configuration/TypoScript/Setup/DynamicContent.typoscript

Configuration/TypoScript/constants.typoscript

@import 'EXT:fluid_styled_content/Configuration/TypoScript/constants.typoscript'

page {
  fluidtemplate {
    layoutRootPath = EXT:site_package/Resources/Private/Layouts/Page/
    partialRootPath = EXT:site_package/Resources/Private/Partials/Page/
    templateRootPath = EXT:site_package/Resources/Private/Templates/Page/
  }
}

Configuration/TypoScript/setup.typoscript

@import 'EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript'
@import 'EXT:site_package/Configuration/TypoScript/Setup/*.typoscript'

page = PAGE
page.10 = FLUIDTEMPLATE
page.10 {
  templateName = TEXT
  templateName {
    cObject = TEXT
    cObject {
      data = pagelayout
      required = 1
      case = ucfirst
      split {
        token = pagets__
        cObjNum = 1
        1.current = 1
      }
    }

    ifEmpty = Default
  }

  templateRootPaths {
    0 = EXT:site_package/Resources/Private/Templates/Page/
    1 = {$page.fluidtemplate.templateRootPath}
  }

  partialRootPaths {
    0 = EXT:site_package/Resources/Private/Partials/Page/
    1 = {$page.fluidtemplate.partialRootPath}
  }

  layoutRootPaths {
    0 = EXT:site_package/Resources/Private/Layouts/Page/
    1 = {$page.fluidtemplate.layoutRootPath}
  }

    dataProcessing {
      10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
      10 {
         levels = 1
         includeSpacer = 1
         as = mainnavigation
      }
   }
}

config {
    admPanel = 1
}

Configuration/TCA/Overrides/sys_template.php

<?php
defined('TYPO3') || die();

call_user_func(function () {
    /**
     * Extension key
     */
    $extensionKey = 'site_package';

    /**
     * Add default TypoScript (constants and setup)
     */
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
        $extensionKey,
        'Configuration/TypoScript',
        'Site Package'
    );
});

Resources/Private/Layouts/Page/Default.html

<f:asset.css identifier="identifier123" href="EXT:site_package/Resources/Public/Css/app.css" />
<f:render section="Main" />

Resources/Private/Templates/Page/Default.html

<f:layout name="Default" />
<f:section name="Main">
    <f:render partial="Navigation/MainNavigation.html" arguments="{_all}"/>
    <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '0'}" />
</f:section>

Resources/Private/Partials/Page/Navigation/MainNavigation.html

<nav>
    <ul>
        <f:for each="{mainnavigation}" as="mainnavigationItem">
        <li class="{f:if(condition: mainnavigationItem.active, then: 'active')}">
            <a 
                href="{mainnavigationItem.link}"
                target="{mainnavigationItem.target}"
                title="{mainnavigationItem.title}"
                >
                {mainnavigationItem.title}
            </a>
        </li>
        </f:for>
    </ul>
</nav>

Configuration/TsConfig/Page/Page.tsconfig

@import 'EXT:site_package/Configuration/TsConfig/Page/PageLayout/*.tsconfig'

Configuration/TsConfig/Page/PageLayout/Default.tsconfig

mod.web_layout.BackendLayouts {
    Default {
        title = Default Layout
        config {
            backend_layout {
                colCount = 1
                rowCount = 1
                rows {
                    1 {
                        columns {
                            1 {
                                name = Main
                                colPos = 0
                            }
                        }
                    }
                }
            }
        }
    }
}

Configuration/TypoScript/Setup/DynamicContent.typoscript

lib.dynamicContent = COA
lib.dynamicContent {
    5 = LOAD_REGISTER
    5 {
        colPos.cObject = TEXT
        colPos.cObject {
            field = colPos
            ifEmpty.cObject = TEXT
            ifEmpty.cObject {
                value.current = 1
                ifEmpty = 0
            }
        }
        pageUid.cObject = TEXT
        pageUid.cObject {
            field = pageUid
            ifEmpty.data = TSFE:id
        }
        contentFromPid.cObject = TEXT
        contentFromPid.cObject {
            data = DB:pages:{register:pageUid}:content_from_pid
            data.insertData = 1
        }
        wrap.cObject = TEXT
        wrap.cObject {
            field = wrap
        }
    }
    20 = CONTENT
    20 {
        table = tt_content
        select {
            includeRecordsWithoutDefaultTranslation = 1
            orderBy = sorting
            where = {#colPos}={register:colPos}
            where.insertData = 1
            pidInList.data = register:pageUid
            pidInList.override.data = register:contentFromPid
        }
        stdWrap {
            dataWrap = {register:wrap}
            required = 1
        }
    }
    90 = RESTORE_REGISTER
}

Configuration/TCA/Overrides/pages.php

<?php

defined('TYPO3') || die();

(static function () {
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
        'site_package',
        'Configuration/TsConfig/Page/Page.tsconfig',
        'Site Package Config'
    );
})();

@linawolf
Copy link

I would opt to also using dataprocessors to display the content as described in the site package tutorial:

https://docs.typo3.org/m/typo3/tutorial-sitepackage/main/en-us/ContentMapping/Index.html#content-rendering-via-data-processing

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