Search
Other Articles Anywhere questions
Forum

Can't find the error in my syntax of nested articles

Thomas Venugopal's Avatar Thomas Venugopal
Hello,

I have this code:
{articles category="286" ordering="id"}
              <div class="uk-display-block">
                {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
                &nbsp;&nbsp;<a class="uk-link-heading" href="{article-sublinelink category="286"}kampagne-erstellen/?sl=[id]{articles-urlba category="267" id="input:ba" include-child-categories="true"}&ba=[id]{/articles-urlba}{articles-urlbtn category="266" id="input:btn"}&btn=[id]{/articles-urlbtn}{articles-urlhr category="262" id="input:hr" include-child-categories="true"}&hr=[id]{/articles-urlhr}{articles-urlbp category="285,288" id="input:bp"}&bp=[id]{/articles-urlbp}{articles-urlhl category="262" id="input:hl" include-child-categories="true"}&hl=[id]{/articles-urlhl}{articles-urlalert category="205" id="input:alert" include-child-categories="true"}&alert=[id]{/articles-urlalert}{articles-urll category="291" id="input:l" include-child-categories="true"}&l=[id]{/articles-urll}{/article-sublinelink}">[text]</a>
              </div>
              {/articles}

In Joomla 4 after the migration the link is broken. As soon as I put the link outside of the nested tag the link does work:
<a class="uk-link-heading" href="{article-sublinelink category="286"}kampagne-erstellen/?sl=[id]{articles-urlba category="267" id="input:ba" include-child-categories="true"}&ba=[id]{/articles-urlba}{articles-urlbtn category="266" id="input:btn"}&btn=[id]{/articles-urlbtn}{articles-urlhr category="262" id="input:hr" include-child-categories="true"}&hr=[id]{/articles-urlhr}{articles-urlbp category="285,288" id="input:bp"}&bp=[id]{/articles-urlbp}{articles-urlhl category="262" id="input:hl" include-child-categories="true"}&hl=[id]{/articles-urlhl}{articles-urlalert category="205" id="input:alert" include-child-categories="true"}&alert=[id]{/articles-urlalert}{articles-urll category="291" id="input:l" include-child-categories="true"}&l=[id]{/articles-urll}{/article-sublinelink}">[text]</a>

What am I doing wrong?
Peter van Westen's Avatar Peter van Westen ADMIN
I don't get why you are using all those nested {article} and {articles} tags...
Doesn't make much sense.
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
Because I'm pulling different parts from different categories. What would be the better way and why does it work standalone but not in the main tag?
Peter van Westen's Avatar Peter van Westen ADMIN
{articles category="286" ordering="id"}
   ...
   {article-sublinelink category="286"}
      [id]
   ...
      {articles-urlba category="267" id="input:ba" include-child-categories="true"
         [id]
      {/articles-urlba}
      ...
   {/article-sublinelink}
   [text]
{/article}
vs:
{articles category="286" ordering="id"}
   ...
   [id]
   ...
   {articles-urlba id="input:ba" category="267" include-child-categories="true"
      [id]
   {/articles-urlba}
   ...
   [text]
{/article}

Hard to tell what you are doing and why.
Why use the extra {article-sublinelink category="286"} tag?

And in the end, what parts are not working?

I recommend you test the separate tags, so you can see what is going on.
Something like:
{articles category="286" ordering="id"}
ID: [id]
{article-sublinelink category="286"}
sublinelink ID: [id]
{articles-urlba category="267" id="input:ba" include-child-categories="true"
urlba ID: [id]
{/articles-urlba}

... etc ...

{/article-sublinelink}
{/article}
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
As soon as I remove the <div class="uk-display-block"> it does work as expected. The same code worked in Joomla 3 (beside the syntax changes).

WORKS in J4:
{articles category="286" ordering="id"}
                            {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
      &nbsp;&nbsp;<a class="uk-link-heading" href="kampagne-erstellen/?sl=[id]{articles-urlba category="267" id="input:ba" include-child-categories="true"}&ba=[id]{/articles-urlba}{articles-urlbtn category="266" id="input:btn"}&btn=[id]{/articles-urlbtn}{articles-urlhr category="262" id="input:hr" include-child-categories="true"}&hr=[id]{/articles-urlhr}{articles-urlbp category="285,288" id="input:bp"}&bp=[id]{/articles-urlbp}{articles-urlhl category="262" id="input:hl" include-child-categories="true"}&hl=[id]{/articles-urlhl}{articles-urlalert category="205" id="input:alert" include-child-categories="true"}&alert=[id]{/articles-urlalert}{articles-urll category="291" id="input:l" include-child-categories="true"}&l=[id]{/articles-urll}">[text]</a>
    		{/articles}

DOES NOT WORK in J4:
{articles category="286" ordering="id"}
              <div class="uk-display-block">
                {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
                &nbsp;&nbsp;<a class="uk-link-heading" href="kampagne-erstellen/?sl=[id]{articles-urlba category="267" id="input:ba" include-child-categories="true"}&ba=[id]{/articles-urlba}{articles-urlbtn category="266" id="input:btn"}&btn=[id]{/articles-urlbtn}{articles-urlhr category="262" id="input:hr" include-child-categories="true"}&hr=[id]{/articles-urlhr}{articles-urlbp category="285,288" id="input:bp"}&bp=[id]{/articles-urlbp}{articles-urlhl category="262" id="input:hl" include-child-categories="true"}&hl=[id]{/articles-urlhl}{articles-urlalert category="205" id="input:alert" include-child-categories="true"}&alert=[id]{/articles-urlalert}{articles-urll category="291" id="input:l" include-child-categories="true"}&l=[id]{/articles-urll}">[text]</a>
              </div>
              {/articles}
Peter van Westen's Avatar Peter van Westen ADMIN
Try placing <p>…</p> tags around the opening and closing {articles} tags.
<p>{articles category="286" ordering="id"}</p>
  <div class="uk-display-block">
   … 
  </div>
<p>{/articles}</p>
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
If I put the p tags around the article tags as advised a part of the output works until the first nested article-tag and I get this output:
kampagne-erstellen/?sl=1058{articles-urlba%20category=
Peter van Westen's Avatar Peter van Westen ADMIN
It is probably due to the system plugin ordering. Try changing the ordering of the plugins.
See: regularlabs.com/blog/242-plugin-order-is-important
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
I tried different orderings, but nothing changed.
Peter van Westen's Avatar Peter van Westen ADMIN
I recommend you start testing from the start. So just the outer {articles} tag and the div tags.
Then add the {ifs}.
Then add the link tag with just 1 nested {articles} tag. Etc....
That way you can see when things go haywire.
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
This is exactly how I wrote the code. Step by step. And it worked for months in J3 (and in J4 until an extension update, I suppose).

But I did it again and in fact as soon as I put the div element inside the output is broken.

Again: Everything works fine how I wish and it works as expected. But as soon as I put the div inside the output is broken. Please investigate on your side.

DOES WORK:
{articles category="286" ordering="id"}
                {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
                &nbsp;&nbsp;<a class="uk-link-heading" href="kampagne-erstellen/?sl=[id]{articles-urlba category="267" id="input:ba" include-child-categories="true"}&ba=[id]{/articles-urlba}{articles-urlbtn category="266" id="input:btn"}&btn=[id]{/articles-urlbtn}{articles-urlhr category="262" id="input:hr" include-child-categories="true"}&hr=[id]{/articles-urlhr}{articles-urlbp category="285,288" id="input:bp"}&bp=[id]{/articles-urlbp}{articles-urlhl category="262" id="input:hl" include-child-categories="true"}&hl=[id]{/articles-urlhl}{articles-urlalert category="205" id="input:alert" include-child-categories="true"}&alert=[id]{/articles-urlalert}{articles-urll category="291" id="input:l" include-child-categories="true"}&l=[id]{/articles-urll}">[text]</a>
            {/articles}

DOES NOT WORK:
{articles category="286" ordering="id"}
                <div>
                {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
                &nbsp;&nbsp;<a class="uk-link-heading" href="kampagne-erstellen/?sl=[id]{articles-urlba category="267" id="input:ba" include-child-categories="true"}&ba=[id]{/articles-urlba}{articles-urlbtn category="266" id="input:btn"}&btn=[id]{/articles-urlbtn}{articles-urlhr category="262" id="input:hr" include-child-categories="true"}&hr=[id]{/articles-urlhr}{articles-urlbp category="285,288" id="input:bp"}&bp=[id]{/articles-urlbp}{articles-urlhl category="262" id="input:hl" include-child-categories="true"}&hl=[id]{/articles-urlhl}{articles-urlalert category="205" id="input:alert" include-child-categories="true"}&alert=[id]{/articles-urlalert}{articles-urll category="291" id="input:l" include-child-categories="true"}&l=[id]{/articles-urll}">[text]</a>
            </div>
            {/articles}
Peter van Westen's Avatar Peter van Westen ADMIN
Sounds like you are putting the <div> tag as last.

My question was, if you start with that, when does it break?
for instance, does this still work?
            {articles category="286" ordering="id"}
            <div>
                {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
            </div>
            {/articles}
etc.
And if so, does this still work?
            {articles category="286" ordering="id"}
            <div>
                {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
                &nbsp;&nbsp;<a class="uk-link-heading" href="#">[text]</a>
            </div>
            {/articles}
[/code]
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
DOES WORK:
            {articles category="286" ordering="id"}
            <div>
                {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
            </div>
            {/articles}

DOES WORK:
                        {articles category="286" ordering="id"}
            <div>
                {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
                &nbsp;&nbsp;<a class="uk-link-heading" href="#">[text]</a>
            </div>
            {/articles}


DOES WORK:
                        {articles category="286" ordering="id"}
            <div>
                {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
                &nbsp;&nbsp;<a class="uk-link-heading" href="kampagne-erstellen/?sl=[id]">[text]</a>
            </div>
            {/articles}



DOES NOT WORK:
            {articles category="286" ordering="id"}
            <div>
                {if input:sl=id}
                <span class="testdrive-id testdrive-id-on">[id]</span>
                {else}
                <span class="testdrive-id">[id]</span>
                {/if}
                &nbsp;&nbsp;<a class="uk-link-heading" href="kampagne-erstellen/?sl=[id]{articles-urlba category="267" id="input:ba" include-child-categories="true"}&ba=[id]{/articles-urlba}">[text]</a>
            </div>
            {/articles}


Additional infop from my first post:
As soon as I put the link outside of the nested tag the link does work:
Peter van Westen's Avatar Peter van Westen ADMIN
Well, that 3rd one doesn't have a closing tag for the {articles-urlba}.
So yes, that would break.
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
Sorry, something went wrong when copy/paste. I updated the code how it is in the joomla module I use. It still does not work with the closing tag.
Peter van Westen's Avatar Peter van Westen ADMIN
Please try the latest development version from:
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
same same
Peter van Westen's Avatar Peter van Westen ADMIN
I think this is most probably due to you using [text] inside an <a> tag.
The [text] will contain <p> tags and other elements. You can't place those inside a link. That is invalid HTML.

See what happens if you use [text html="false"] instead.
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
No change, still doesn't work. Tested with latest dev-version.
PS: In Joomla 3 was no output with a p-tag for [text].
Peter van Westen's Avatar Peter van Westen ADMIN
Try switching off the 'Fix HTML' option in the Articles Anywhere system plugin settings.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription