0
Welcome Guest! Login
0 items Join Now

Adding custom module position cause double rendered modules on site

  • Adding custom module position cause double rendered modules on site

    Posted 10 years 8 months ago
    • Reproduction:
      * Gantry Rocketlauncher v4.2.21 (After install update to latest joomla, purge chaches)

      ### Edit template
      add html in index.php
      This image is hidden for guests.
      Please log in or register to see it.


      add positions to templateDetails.xml
      This image is hidden for guests.
      Please log in or register to see it.


      add layout to template-options.xml
      This image is hidden for guests.
      Please log in or register to see it.



      Setup a custom module to fullwidthmenu-a position with simple <h1> tag content


      Result:
      This image is hidden for guests.
      Please log in or register to see it.



      After inspecting the code in the browser, i'll noticed that the module is rendered too in fullwidth
      This image is hidden for guests.
      Please log in or register to see it.



      ### Scenario 2
      The same results you'll get if you add 2 modulepositions with similar names, like (headertop and headerbottom):
              <fields name="headertop" type="position" label="HEADERTOP_POS" description="LAYOUT_POS_DESC">
                  <field name="layout" type="positions" default="3,3,3,3" label="">
                      <schemas>1,2,3,4,5,6</schemas>
                      <words>2,3,4,5,6,7,8,9,10</words>
                  </field>
                  <field name="showall" type="toggle" default="0" label="FORCE_POS"/>
                  <field name="showmax" type="showmax" default="6" label="POS_COUNT"/>
              </fields>
      
      
              <fields name="header" type="position" label="HEADER_POS" description="LAYOUT_POS_DESC">
                  <field name="layout" type="positions" default="3,3,3,3" label="">
                      <schemas>1,2,3,4,5,6</schemas>
                      <words>2,3,4,5,6,7,8,9,10</words>
                  </field>
                  <field name="showall" type="toggle" default="0" label="FORCE_POS"/>
                  <field name="showmax" type="showmax" default="6" label="POS_COUNT"/>
              </fields>
      
              <fields name="headerbottom" type="position" label="HEADERBOTTOM_POS" description="LAYOUT_POS_DESC">
                  <field name="layout" type="positions" default="3,3,3,3" label="">
                      <schemas>1,2,3,4,5,6</schemas>
                      <words>2,3,4,5,6,7,8,9,10</words>
                  </field>
                  <field name="showall" type="toggle" default="0" label="FORCE_POS"/>
                  <field name="showmax" type="showmax" default="6" label="POS_COUNT"/>
              </fields>

      If you use 2 complete different positions, like name="overthehead" and name="underheadmodules" the modules rendered correctly


      But i used the naming style as seen in template-options.xml (example: maintop, mainbottom)
             <fields name="maintop" type="position" label="MAINTOP_POS" description="LAYOUT_POS_DESC">
                  <field name="layout" type="positions" default="3,3,3,3" label="">
                      <schemas>1,2,3,4,5,6</schemas>
                      <words>2,3,4,5,6,7,8,9,10</words>
                  </field>
                  <field name="showall" type="toggle" default="0" label="FORCE_POS"/>
                  <field name="showmax" type="showmax" default="6" label="POS_COUNT"/>
              </fields>
      
              <field name="mainbodyPosition" type="positions" default="6,3,3" label="MAINBODY_POS" description="LAYOUT_POS_DESC">
                  <schemas>1,2,3,4</schemas>
                  <words>sa,sb,sc,mb</words>
                  <type>custom</type>
              </field>
      
              <fields name="mainbottom" type="position" label="MAINBOTTOM_POS" description="LAYOUT_POS_DESC">
                  <field name="layout" type="positions" default="3,3,3,3" label="">
                      <schemas>1,2,3,4,5,6</schemas>
                      <words>2,3,4,5,6,7,8,9,10</words>
                  </field>
                  <field name="showall" type="toggle" default="0" label="FORCE_POS"/>
                  <field name="showmax" type="showmax" default="6" label="POS_COUNT"/>
              </fields>

      ### Scenario 3
      • add <position>fullwidthmenu</position> to templateDetails.xml
      • add no layout to template-options.xml
      • index.php: Code as above

      Same results as in 1 + 2
    • Last Edit: 10 years 8 months ago by Lahmizzar V.
    • Why i am doing what i do? Sometimes it simply came over me!

      Don't forget to hit the THANKS button for those who helped you and for those who need this for their alter ego :)
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: Adding custom module position cause double rendered modules on site

    Posted 10 years 8 months ago
    • ... right now I can only confirm the issue ... workaround is (as you already menioned) to use unique names for the positions.
  • Re: Adding custom module position cause double rendered modules on site

    Posted 10 years 8 months ago
    • Found the code where the problem possibly related to:
      Regex in the libraries/gantry/core/gantrytemplate.class.php -> parsePosition() method on initial parsing positions
      	/**
      	 * @param $position
      	 * @param $pattern
      	 *
      	 * @return array
      	 */
      	public function parsePosition($position, $pattern)
      	{
      		$filtered_positions = array();
      		if (count($this->positions) > 0) {
      			if (!array_key_exists($position, $this->cached_possitions)) {
      				if (null == $pattern) {
      					$pattern = "(-)?";
      				}
      				$regpat = "/^" . $position . $pattern . "/";
      				foreach ($this->positions as $key => $value) {
      					if (preg_match($regpat, $value) == 1) {
      						$filtered_positions[] = $value;
      					}
      				}
      				$this->cached_possitions[$position] = $filtered_positions;
      			}
      		} else {
      			return $filtered_positions;
      		}
      		return $this->cached_possitions[$position];
      	}

      If for example parsing the header position, this gets also headertop, headerbottom (if headertop and headerbottom are custom added positions...
    • Last Edit: 10 years 8 months ago by Lahmizzar V. Reason: edit file path
    • Why i am doing what i do? Sometimes it simply came over me!

      Don't forget to hit the THANKS button for those who helped you and for those who need this for their alter ego :)
  • Re: Adding custom module position cause double rendered modules on site

    Posted 10 years 8 months ago
    • If i'm right that $pattern is "-a" - "-f", then a tightr regex that match the end of a positionstring too could solve this. I've tested this with latest gantry and epsilon template with modules published in every position and it seems that everything works as intended now.

      Diff: Line 13 + line 15 - additional regular expression
      	/**
      	 * @param $position
      	 * @param $pattern
      	 *
      	 * @return array
      	 */
      	public function parsePosition($position, $pattern)
      	{
      		$filtered_positions = array();
      		if (count($this->positions) > 0) {
      			if (!array_key_exists($position, $this->cached_possitions)) {
      				if (null == $pattern) {
      					$pattern = "(-)?[a-f]?";
      				}
      				$regpat = "/^" . $position . $pattern . "$/";
      				foreach ($this->positions as $key => $value) {
      					if (preg_match($regpat, $value) == 1) {
      						$filtered_positions[] = $value;
      					}
      				}
      				$this->cached_possitions[$position] = $filtered_positions;
      			}
      		} else {
      			return $filtered_positions;
      		}
      		return $this->cached_possitions[$position];
      	}
    • Last Edit: 10 years 8 months ago by Lahmizzar V.
    • Why i am doing what i do? Sometimes it simply came over me!

      Don't forget to hit the THANKS button for those who helped you and for those who need this for their alter ego :)
    • Elliance's Avatar
    • Elliance
    • Jr. Rocketeer
    • Posts: 21
    • Thanks: 0

    Re: Adding custom module position cause double rendered modules on site

    Posted 10 years 8 months ago
    • Is this the same problem I am experiencing?

      I fixed the file gantrytemplate.class.php with $pattern = "(-)?[a-f]?"; on line 340, but to no avail.

      I do not understand the suggested work around.

      See www.elliance.nl/paradigm-rocketlauncher_...positions-in-werking

      Best regards, Cynthia


      This image is hidden for guests.
      Please log in or register to see it.
  • Re: Adding custom module position cause double rendered modules on site

    Posted 10 years 7 months ago
    • Elliance wrote:
      Is this the same problem I am experiencing?

      Yes, this is exact the same problem
      Elliance wrote:
      I fixed the file gantrytemplate.class.php with $pattern = "(-)?[a-f]?"; on line 340, but to no avail.

      Have you changed line 342, too?
      $regpat = "/^" . $position . $pattern . "$/";

      Elliance wrote:
      I do not understand the suggested work around.

      I'll try to keep my expl. very short

      The position with the shortest name have lets say: "ghost copies" in. That is because you have added custom module positions with a name which starts exactly as exsiting positions.

      headersuperhero-a ==> One published module, everything is ok
      header ==> Here's the "ghost copy"

      feature1-a ==> One published module, everything is ok
      feature ==> Here's the "ghost copy"


      custommodulefeature1000-a ==> One published module, everything is ok
      custommodulefeature1000 ==> Here's the "ghost copy"
      custommodulefeature1 ==> Here's also a "ghost copy"
      custommodulefeature ==> Here's also a "ghost copy"
      custommodulefea ==> Here's also a "ghost copy"
      custommodule ==> Here's also a "ghost copy"
      custom ==> Here's also a "ghost copy"



      Hope it is only line 342 :)

      reg. lahmizar


      note: this is a post from my mobile at the pool bar in my holidays, and i have drunk a lot..., maybe i am wrong with my explanation in this post... couldn't read my posts above ;). possible revise if i am back..
    • Last Edit: 10 years 7 months ago by Lahmizzar V.
    • The following users have thanked you: Elliance, TGoodrich

    • Why i am doing what i do? Sometimes it simply came over me!

      Don't forget to hit the THANKS button for those who helped you and for those who need this for their alter ego :)
    • Elliance's Avatar
    • Elliance
    • Jr. Rocketeer
    • Posts: 21
    • Thanks: 0

    Re: Adding custom module position cause double rendered modules on site

    Posted 10 years 7 months ago
    • Thank you Lahmizar for getting back to me so quickly whilst you are on holiday.

      Line 342 did the trick!! I overlooked the dollar sign (how can I overlook that! ;-)).

      Enjoy the pool bar!

      Best regards, Cynthia
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: Adding custom module position cause double rendered modules on site

    Posted 10 years 7 months ago
    • btw. Kat did add a ticket for this in our bug tracker ...
    • The following users have thanked you: Lahmizzar V

  • Re: Adding custom module position cause double rendered modules on site

    Posted 10 years 3 months ago
    • Hi All,

      I had this same issue with the Anacron 1.2 Template using Gantry v4.1.25 .

      I applied Lahmizzar M's fix and things are now working as they should.

      Hopefully this fix will make it into the next Gantry update.

      Thanks for posting a fix Lahmizzar M. It is very much appreciated.

      Kind Regards,
      Tracey
  • Re: Adding custom module position cause double rendered modules on site

    Posted 9 years 11 months ago
    • Hi,

      I finally just did the update to Gantry v4.1.26 and found this is still an issue in Gantry. After the update my live site was broken in a big way. Thankfully I remembered this issue and found this thread again. I had to re-apply the fix outlined in this thread to fix the problem.

      Is there any plans on a permanent fix in the next Gantry update?

      Three of us have confirmed this problem going back 9 months and I am very surprised this simple fix hasn't been addressed/implemented by the Gantry Devs yet.

      Not to sound like a whiner but if i had forgot about this issue it could have taken hours or even days to find and fix this problem. My site was so broken I would have had to take it down while trying fix it. For me this would have been pretty bad as our site is for a local government entity.

      Rockettheme Support, please confirm you have read this and let us know if anything will be done about it.

      Thank you

Time to create page: 0.064 seconds