Please note that Form2Content is no longer being developed. All files from the latest version can be found on Github.

Form2Content Forum

Questions and answers for Form2Content, a Joomla CCK.
  1. Jeroen
  2. F2C article templating
  3. Friday, 25 October 2019
  4.  Subscribe via email
I post this question for the second time because the post prior to this one won't open for some reason.

We use Joomla 3.9.12 and Form2Content 6.17.4
We have upgraded from PHP 7.1 to PHP 7.2

All articles generated with Form2Content are OK but when we make a new a article we get a few notices which start with:
Notice: Undefined offset: 0 in /home/sites/.../nameoftemplate_sjabl_intro.tpl.php
I think it has something to do with:

{if $AFBEELDINGEN_IMAGES[0]}</div>{/if}

If I add an image there is no problem.
If I don't add an image the Notice becomes visible.
If I select the article and click on the button "Refresh" the notice is gone.

What could be wrong with the code?

{if $AFBEELDINGEN_IMAGES[0]}</div>{/if}
Accepted Answer
Accepted Answer Pending Moderation
Hello Jeroen,

You are accessing the first element of the $AFBEELDINGEN_IMAGES array: $AFBEELDINGEN_IMAGES[0]
But when there are no images, there is no first element and that is what the notice is reporting.

You should first test if there are any images like this:

{if $AFBEELDINGEN_IMAGES} ..... your template code ...... {/if}

Inside the if statement you can then safely access the first element: $AFBEELDINGEN_IMAGES[0]

best,
Julien
Responses (3)
Accepted Answer Pending Moderation
Hi Jeroen,

A technical one indeed. I will ask Julien to have a look. I do believe there are also different ways to check if an array has a value. Or do you need check this specific image?

Regards,
Patrick
Please read the F2C documentation before asking questions! Thank you if you've done so ;)
  1. more than a month ago
  2. F2C article templating
  3. # 1
Accepted Answer Pending Moderation
Thank you Julien!
It solved the problem.
  1. more than a month ago
  2. F2C article templating
  3. # 2
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.