Search
Other Articles Anywhere questions
Forum

non existing custom field gives output anyway

Remco Janssen's Avatar Remco Janssen
Hi,

I have the following code that I use in combination with a custom field for products in j2store. For a typical category the custom field 'afmetingen' is not availabe, hence it is not supposed to contain any value.
But suddenly the code does output data.
{if afmetingen}Afmetingen in cm: [afmetingen]{/i}

I checked the product and the database, but there is no value set for 'afmetingen'. And still it outputs data!

This is the complete code:
{articles <?php echo $this->product->source->id; ?>}
<div itemscope itemtype="https://schema.org/Product" class="product-<?php echo $this->product->j2store_product_id; ?> <?php echo $this->product->product_type; ?>-product">
    <div class="row">
        <div class="col-12 col-sm-12 col-md-6">
            [image-fulltext width="540" height="540"]
            <div class="additional-images">
                <div class="row">
                    <?php for ($t=1;$t<7;$t++) {?>
                        {if afbeelding-<?php echo $t; ?>}
                        <div class="additional-image">
                            [afbeelding-<?php echo $t; ?> width="90" height="90" layout="templates/shaper_helixultimate/html/layouts/com_fields/image_field.php"]

                        </div>
                        {/if}
                    <?php } ?>
                </div>
            </div>


            <?php
            $images = $this->loadTemplate('images');
            J2Store::plugin()->event('BeforeDisplayImages', array(&$images, $this, 'com_j2store.products.view.default'));

            echo $images;
            ?>


        </div>


        <div class="col-12 col-sm-12 col-md-6">

            <?php echo $this->loadTemplate('title'); ?>
            [tags]
            <?php if(isset($this->product->source->event->afterDisplayTitle)) : ?>
                <?php echo $this->product->source->event->afterDisplayTitle; ?>
            <?php endif;?>
            <?php if($this->params->get('item_use_tabs', 1)): ?>
                <!-- gebruik altijd notabs -->
                <?php echo $this->loadTemplate('notabs'); ?>
            <?php else: ?>
                <?php echo $this->loadTemplate('notabs'); ?>
            <?php endif; ?>
            <div class="price-sku-brand-container row-fluid">
                <div class="">
                    <?php
                    $show = J2Store::product ()->validateVariableProduct($this->product);
                    if ($show) {
                        echo $this->loadTemplate('price');
                    }
                    ?>


                </div>

                <div class="">
                    <?php if(isset($this->product->source->event->beforeDisplayContent)) : ?>
                        <?php echo $this->product->source->event->beforeDisplayContent; ?>
                    <?php endif;?>

                    <?php

                    ?>
                    {if kleur!="none"}Kleur: <a href="/meubel-op-maat/kleuren-van-firma-zoethout">[kleur]</a><br />{/if}
<!-- THIS IS WHERE IT IS GOING WRONG: -->
                    {if afmetingen}Afmetingen in cm: [afmetingen]{/if}

                    <?php echo $this->loadTemplate('sku'); ?>
                    <?php echo $this->loadTemplate('brand'); ?>
                    <?php if($this->params->get('item_show_product_stock', 1) && J2Store::product()->managing_stock($this->product->variant)) : ?>
                        <?php echo $this->loadTemplate('stock'); ?>
                    <?php endif; ?>
                </div>
            </div>
            {if artikelstatus=="reserved"}
            <?php echo JText::_('J2STORE_OUT_OF_RESERVED'); ?>

            {/if}
            {if artikelstatus!="reserved"}

            <?php if( J2Store::product()->canShowCart($this->params) ): ?>

                <form action="<?php echo $this->product->cart_form_action; ?>"
                      method="post" class="j2store-addtocart-form"
                      id="j2store-addtocart-form-<?php echo $this->product->j2store_product_id; ?>"
                      name="j2store-addtocart-form-<?php echo $this->product->j2store_product_id; ?>"
                      data-product_id="<?php echo $this->product->j2store_product_id; ?>"
                      data-product_type="<?php echo $this->product->product_type; ?>"
                      enctype="multipart/form-data">

                    <?php echo $this->loadTemplate('options'); ?>
                    <?php echo $this->loadTemplate('cart'); ?>

                </form>
            <?php endif; ?>
            {/if}
        </div>
    </div>


    <?php if(isset($this->product->source->event->afterDisplayContent)) : ?>
        <?php echo $this->product->source->event->afterDisplayContent; ?>
    <?php endif;?>
</div>
{/articles}

I fixed it for now by adding a category check:
{if category!="onze verf"}
  {if afmetingen}Afmetingen in cm: [afmetingen]{/if}

Oh and I noticed that if I close the first if: {/if} shows up in the page, so I removed it again. which works.
Remco Janssen's Avatar Remco Janssen
It outputs:
100 (h) x 50 (b) x 20 (d)
which is a valid value for other products, but not set for this one.

you can check it at: filters.firmazoethout.nl/vintage-kinderm...ls/onze-verf/linnen0
which is my development url
Andrea Malalana's Avatar Andrea Malalana
That's weird. There might be some syntax going weird.

One thing that jumps to me is that you're using the {articles} tag for one single article. You should use the {article} tag instead.

Try to test with a simplified syntax and see if it still happens. Try with just:
{article id="<?php echo $this->product->source->id; ?>"}
[afmetingen]
{/article}

Does it still output it?

Also: Are you using the latest version of Articles Anywhere? Make sure you are using it.
Remco Janssen's Avatar Remco Janssen
Hi, Yes latest version, also of Joomla!(3)

Now using this:
{article id="<?php echo $this->product->source->id; ?>"}
{if afmetingen}afmetingen in cm: [afmetingen]{/if}
{/article}

Which stills shows it.
Andrea Malalana's Avatar Andrea Malalana
Can you give me (super) admin and (s)ftp access so I can take a look?
And tell me on what article I can see/reproduce the issue.
You can use the 'Confidential information' button in the forum editor to hide sensitive information.
Remco Janssen's Avatar Remco Janssen
Here goes:

Confidential information:
(hidden)
Andrea Malalana's Avatar Andrea Malalana
Go in Fields -> Afmetingen.

Check the "Default Value". Remove it 🙂

This was my first suspect.

If you put a default value, that will be output by default when the saved value is empty.
Remco Janssen's Avatar Remco Janssen
Ok, but I still think it is strange that a custom field that is not connected to this article does ‘exist’. It wasn’t showing this before (sorry I don’t know after which update)
And I need the default value for the customers sake.
Andrea Malalana's Avatar Andrea Malalana
Ok, then maybe Peter can fix this.

If the field is not associated to the category of the current article, don't inherit the field's default value.

I'll leave that to him 🙂 @Peter
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
Remco Janssen's Avatar Remco Janssen
Hi Peter & Andrea,

Sorry for the late reply. Installing the Dev release fixed the issue!

Thanks for the support!

Kind regards,
Remco
Peter van Westen's Avatar Peter van Westen ADMIN
Ok, great 🙂
The fix will be included in the next release.
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