Installing pagetype using the CIF XML file and too many formlayout sets

Hi! :slightly_smiling_face:

I’ve been trying to use CIF XML files for creating automatic content in a package. I couldn’t find much documentation about this.

After looking into concrete’s build-in themes xml files and many times failing and trying again I was able to create a new pagetype almost correctly.

But somehow the new pagetype’s composer got so many duplicated formlayout sets. It seems it is always creating a new formlayout set, when I do the xml-file install again. Is this supposed to happen and can I prevent it somehow? Should I always delete the pagetype before installing CIF content again (and how to do that)?

So the pagetypes composer form looks like this:

There’s the CIF I’m using (install/page_types.xml):

<?xml version="1.0"?>
<concrete5-cif version="1.0">
 
  <pagetypes>
    <pagetype name="News Entry" handle="news_entry" is-frequently-added="1" launch-in-composer="1">
      <pagetemplates type="custom" default="news">
        <pagetemplate handle="news" />
      </pagetemplates>
      <target handle="page_type" package="" pagetype="news"/>
      <composer>
          <formlayout>
              <set name="Post Details">
                  <control custom-template="" custom-label="Entry Name" type="core_page_property" handle="name"/>
                  <control custom-template="" custom-label="" type="core_page_property" handle="url_slug"/>
                  <control custom-template="" custom-label="Short Description" type="core_page_property"
                            handle="description"/>
                  <control custom-template="" type="core_page_property" handle="publish_target"/>
              </set>
              <set name="Content">
                  <control custom-template="" custom-label="" type="collection_attribute" handle="thumbnail"/>
                  <control custom-template="" custom-label="" output-control-id="6y4mB58T" type="block"
                            handle="content"/>
              </set>
          </formlayout>
          <output>
              <pagetemplate handle="news">
                  <page name="" path="" filename="" pagetype="news_entry" template="news" user="admin"
                        description="" package="subnet_theme">
                      <area name="Page Header">
                          <blocks>
                              <block type="breadcrumbs" name="" mc-block-id="auf8nvkdiz">
                                  <data table="btBreadcrumbs">
                                      <record>
                                          <includeCurrent><![CDATA[0]]></includeCurrent>
                                          <ignoreExcludeNav><![CDATA[1]]></ignoreExcludeNav>
                                          <ignorePermission><![CDATA[0]]></ignorePermission>
                                      </record>
                                  </data>
                              </block>
                              <block type="page_title" name="" custom-template="byline.php"
                                      mc-block-id="3zXqs3ea">
                                  <data table="btPageTitle">
                                      <record>
                                          <useCustomTitle><![CDATA[0]]></useCustomTitle>
                                          <titleText><![CDATA[[Page Title]]]></titleText>
                                      </record>
                                  </data>
                              </block>
                          </blocks>
                      </area>
                      <area name="Main">
                          <blocks>
                              <block type="core_page_type_composer_control_output" name="" mc-block-id="YVfXXxWY">
                                  <control output-control-id="6y4mB58T"/>
                              </block>
                          </blocks>
                      </area>
                      <area name="Sidebar">
                          <blocks>
                              <block type="next_previous" name="" mc-block-id="71azOVYD">
                                  <data table="btNextPrevious">
                                      <record>
                                          <nextLabel><![CDATA[Next Article]]></nextLabel>
                                          <previousLabel><![CDATA[Previous Article]]></previousLabel>
                                          <parentLabel><![CDATA[]]></parentLabel>
                                          <loopSequence><![CDATA[0]]></loopSequence>
                                          <orderBy><![CDATA[chrono_desc]]></orderBy>
                                      </record>
                                  </data>
                              </block>
                          </blocks>
                      </area>
                  </page>
              </pagetemplate>
          </output>
      </composer>
    </pagetype>

    <pagetype name="News" handle="news" package="subnet_theme" launch-in-composer="1">
        <pagetemplates type="custom" default="full">
            <pagetemplate handle="full"/>
        </pagetemplates>
        <target handle="all" package=""/>
        <composer>
            <formlayout>
                <set name="Details">
                    <control custom-template="" type="core_page_property" handle="name"/>
                    <control custom-template="" custom-label="" type="core_page_property" handle="publish_target"/>
                </set>
            </formlayout>
        </composer>
    </pagetype>
  </pagetypes>

</concrete5-cif>

And in controller.php I’m using this to install content:

$this->installContentFile('install/page_types.xml');

Thanks!

I have found this to happen also, I use the CIF XML format for my install and upgrade and if you have things in there to create page type settings they will get added every time you update your package. It’s almost like you need a new XML file for each update or something, which is not at all convenient.

I’ve also found that if you have a Topic Tree defined even if it’s already been created it will wipe out any manually created/updated nodes and reset them to what’s defined in the XML. It will also wipe out any Page Descriptions if you have Pages defined and the values aren’t in the XML.

I thought when they first introduced this they it was said only “changes” would be implemented, but that doesn’t seem to be the case.

Thank you hutman for sharing your experience of this! Good to know that I may come across those other problems too. Have you got any workarounds with this, or is it just better to avoid doing some things with CIF?

Now I’m struggling with the problem how to get all those unnecessary pagetype composer formlayout sets deleted without manual work everytime I accidentally add them with CIF. :sweat_smile:

We don’t build things for the marketplace often so I usually put everything in for the install and then comment it out once the install is complete. It’s not a great solution but it’s what we do.

Look here: Putting it All Together Create the Page Type :: Concrete CMS

Scroll down to the second paragraph under the Export the Page Type to CIF XML heading near the bottom. “If you add this page type to the upgrade method, any time you upgrade you’ll get some duplicated block type content on the page type, and duplicated controls in the forms.”

The way the documentation works is that if you want to know how to work with page types you basically have to read the entire documentation because everything is explained a little bit here, a little bit there, a little bit everywhere. Then you have to read it again several more times until you can remember where all the little bits are located.

Thank you! I totally missed that part, even though I recall reading that page before. So for now, I just don’t make CIF changes to pagetypes after install to avoid the mess.

Yes, but it would be nice to know how to do it on update. But that’s not documented anywhere as far as I know. That entire page is a disgrace. Developers need to know how to use code and that page is about avoiding the code you need to understand how to actually accomplish things.