Trouble assigning page attributes via content.xml

Hello All!

I’m working on a package with a theme and some default initial content. (I haven’t found the documentation to be very helpful, but I’ve found some examples from other packages that I’ve been trying to make sense of.)

In my content.xml file, I’ve setup some attributes, and added a page element for the Home page (root path) so that I could assign it a custom template, and associate the custom page attributes to the Home page.

This all seems to be working. :partying_face:

However, I then added a 2nd page element in the content.xml for a Contact page (/contact) and I’m not getting what I expect. :face_with_peeking_eye:

Although it does create the page and the url path just fine, and it seems to be using the correct template … the attribute is not applied (even though its the same code used for the previous page element which is working).

My ultimate goal is to define/install a set of starting blocks/content into the ‘Main’ area for the Contact page, but at the moment I can’t even get the page attributes working on anything other than the Home (/) page.

Can anyone help me understand why I cannot assign page attributes to the 2nd page:

  <pages>

    <page name="Home" path="" description="" user="admin" template="brochure" filename="" pagetype="" package="my_package_handle" root="true">
      <attributes>
          <attributekey handle="prefab_handle">
              <value>home</value>
          </attributekey>         
      </attributes>    
    </page>
  
    <page name="Contact" path="/contact" description="" user="admin" template="full" filename="" pagetype="" package="my_package_handle">
      <attributes>
          <attributekey handle="prefab_handle">
              <value>contact</value>
          </attributekey>         
      </attributes>             
    </page>    
  
  </pages>

This looks totally correct to me. The only possibility I can think of is an issue with the value “contact”. Are you sure it’s spelled exactly like that? No capital letter, no extra space anywhere?

Well if you mean the ‘value’… I think I can put anything in there and it will just assign that text to the “prefab_handle” attribute. The prefab_handle is defined in the xml as well:

  <attributekeys>
    <attributekey handle="prefab_handle" name="Prefab Handle" package="my_package_handle" searchable="0"
                  indexed="0"
                  type="text" category="collection"/>
  </attributekeys>

  <attributesets>
      <attributeset handle="eoc_attrib_set" name="My Attrib Set" package="my_package_handle" category="collection">
          <attributekey handle="prefab_handle"/>
      </attributeset>
  </attributesets>

If I copy exactly the same ‘attributes’ section to both page elements, the Home page gets a “prefab_handle” attribute with value = “home”, while the Contact page has no custom attributes assigned at all.

Oh I think I figured it out! I went back and reread an earlier thread which you helped me with @mnakalay, and it made me think that the Contacts page element needed the filename=“” attribute filled out and pointing to the view file. I set filename=“full.php” and it seems to be working!

Corrected:

:smile: happy I could help after all

well I may have spoke too soon. I tried adding a page title block and it broke.

Even after rolling back the change to the ‘corrected’ version above, the attributes aren’t working again.

I’m going to walk away for a while and hope that it starts working by magic again. Even if I can get the attributes working again, it seems adding a block breaks it. I dont suppose you have any insight on adding a simple block? I tried adding the following to the contact page element.

<area name="Main">
  <blocks>

  <block type="page_title" name="Page Title">
    <data table="btPageTitle">
      <record>
        <useCustomTitle><![CDATA[1]]></useCustomTitle>
        <useFilterTitle><![CDATA[0]]></useFilterTitle>
        <useFilterTopic><![CDATA[0]]></useFilterTopic>
        <useFilterTag><![CDATA[0]]></useFilterTag>
        <useFilterDate><![CDATA[0]]></useFilterDate>
        <topicTextFormat><![CDATA[0]]></topicTextFormat>
        <tagTextFormat><![CDATA[upperWord]]></tagTextFormat>
        <dateTextFormat><![CDATA[0]]></dateTextFormat>
        <filterDateFormat><![CDATA[F Y]]></filterDateFormat>
        <titleText><![CDATA[Hello World]]></titleText>
        <formatting><![CDATA[h3]]></formatting>
      </record>
    </data>
  </block>

  </blocks>
</area>

I doubt now whether I had it working or not … perhaps I checked the wrong page and thought it was working? I’ve reverted to what I thought was working and it is not. :frowning:

Oh here is a really interesting thing, @mnakalay

Just to see what would happen I reordered the page elements in the xml file such that Contact was defined first in the xml and home was defined 2nd. This time, Contact got an attribute, but Home did not.

For some reason only the first page listed in the xml is getting attribute assignments (or apparently anything else inside the page element), not the next one.

I just tested with 3 page elements. Consistently I’m seeing:

  • All pages get created at the appropriate url
  • All pages use the appropriate template as described in the xml
  • Only the first page listed has the directives within the page element applied.
  • The following pages exist, but ignore elements within it’s page element (such as attributes and blocks).

could you post your full xml file here please?

Sure, thanks. Below is the file as currently exists in my project. The package is installing without error, and each page is created at the correct /path and with the correct template … however …

Only the first page defined in the XML (currently /faq) will get attributes assigned. I’ve changed the order and whichever page is first gets an attribute and the other do not.

I’ve also tested with blocks, and just like with attributes, only the first page will get any blocks defined.

<?xml version="1.0"?>
<concrete5-cif version="1.0">
  
  <themes>
    <theme handle="theme_esperanto_cards" package="esperanto_cards" activated="1"/>
  </themes>
  
  <attributekeys>
    <attributekey handle="prefab_handle" name="Prefab Handle" package="esperanto_cards" searchable="0"
                  indexed="0"
                  type="text" category="collection"/>               
  </attributekeys>

  <attributesets>
      <attributeset handle="eoc_attrib_set" name="Esperanto.cards" package="esperanto_cards" category="collection">
          <attributekey handle="vorto"/>
          <attributekey handle="prefab_handle"/>
      </attributeset>
  </attributesets>  

  <pagetemplates>
    <pagetemplate handle="full" name="Full" icon="full.png" package="esperanto_cards" internal=""/>
    <pagetemplate handle="brochure" name="Brochure" icon="full.png" package="esperanto_cards" internal=""/>
  </pagetemplates>
  
  <pagetypes>
    <pagetype name="Full" handle="full" is-frequently-added="1" launch-in-composer="1">
      <pagetemplates type="all" default="full"/>
      <target handle="all" package=""/>
      <composer>
        <formlayout>
          <set name="Basics">
            <control custom-template="" required="1" custom-label="Page Name" type="core_page_property" handle="name"/>
            <control custom-template="" custom-label="" type="core_page_property" handle="description"/>
            <control custom-template="" custom-label="" type="core_page_property" handle="url_slug"/>
            <control custom-template="" custom-label="" type="core_page_property" handle="page_template"/>
            <control custom-template="" custom-label="" type="core_page_property" handle="publish_target"/>
          </set>
          <set name="Content">
            <control custom-template="" custom-label="Body" output-control-id="EcjltFnE" type="block" handle="content"/>
          </set>
        </formlayout>
        <output>
          <pagetemplate handle="full">
            <page>
              <area name="Main">
                <blocks>
                  <block type="core_page_type_composer_control_output" name="">
                    <control output-control-id="EcjltFnE"/>
                  </block>
                </blocks>
              </area>
            </page>
          </pagetemplate>
        </output>
      </composer>
    </pagetype> 
  </pagetypes>

  <pages>

    <page name="FAQ" path="/faq" description="" user="admin" template="full" filename="" pagetype="full" package="esperanto_cards">
      <attributes>
          <attributekey handle="prefab_handle">
              <value>FAQ</value>
          </attributekey>       
      </attributes>     
    </page>    

    <page name="Contact" path="/contact" description="" user="admin" template="full" filename="" pagetype="full" package="esperanto_cards">
      <attributes>
          <attributekey handle="prefab_handle">
              <value>contact</value>
          </attributekey>
      </attributes>     
    </page>

    <page name="Home" path="" description="" user="admin" template="brochure" filename="" pagetype="" package="esperanto_cards" root="true">
      <attributes>
          <attributekey handle="prefab_handle">
              <value>home</value>
          </attributekey>        
      </attributes>    
    </page>

  </pages>

</concrete5-cif>