custom fields in block4 / td_module_2.php

Posted in: Newspaper
Post count: 11

I modified td_module_2.php to display 2 custom fields – it works fine in categories (http://s752582646.online.de/category/magazin/new-business) but not when I insert block4 as an element (http:// s752582646. online.de, http://s752582646.online.de/magazin)

Furthermore, I would like to change the height of the slider (http://s752582646.online.de/magazin) from 580px to 480px. How can I do that?

Thank you for your help and have a nice day

Post count: 20688

Hi,

The module should look the same everywhere it is used, as you modified it. How exactly did you modify it? Are you using a plugin for the field?

The slide has height settings – http://prntscr.com/mn7yws Enter the value you want there, enter 480 if that is how you want it.

Thanks

Post count: 11

Hi Simion,

thanks for your help.

@custom fields: i used Plugin ACF (Advanced Custom Fields) for the fields and modified td_module_2.php to display them: http://prntscr.com/mn9i9i

I also thought that the module should look the same everywhere – but it does not, as seen in the links above.

@Element Slide: i have no tab “Layout” by the slide settings – see the screenshot: http://prntscr.com/mn9n34

Thank you for your further help.
Best regards
Eugen

Post count: 20688

I tried something simple, like this – http://prntscr.com/mnmtjk
Code used here

<?php the_field('my_field', $this->post->ID); ?>

It works everywhere the module is used – http://prntscr.com/mnmu0t

Regarding the slide, that setting including others were added in update 9.1
http://prntscr.com/mnmuw5
Using older theme versions these will not be available. I could give you some CSS for it
http://prntscr.com/mnmwvi

.iosSlider-col-3,
.iosSlider-col-3 .td_module_slide {
max-height: 480px;
}

Post count: 11

Hi Simion,

i updated Newspaper-Theme to 9.5 – and the slide works fine.

@custom field: i tried to check if value exist (https://www.advancedcustomfields.com/resources/the_field/) as shown in the example http://prntscr.com/mqh9nz – that works in Article Display Wiew M2 (http://s752582646.online.de/category/magazin/new-business) but not by using Block 4 in TD Composer (http://s752582646.online.de/magazin). But i have to check if value exists. So what can i do?

Thanks for your help

Post count: 35449

Hi,

Why you are not using flex blocks, those can be set after your needs
-> https://www.screencast.com/t/Qdn7aLYPn
-> https://www.screencast.com/t/VjbG09vy4
I think this can achieve what you need without to be need to make changes in modules.

Thank you!

Post count: 11

Hi Calin,
i cant see how flex solve my problem.

I’ve added additional input fields (http://prntscr.com/mqxeqt) with the ACF (Advanced Custom Fields) plugin.

I would like to display these values in the article View – for this I modified the file td_module_2.php.
With “<?php the_field(‘kontext-titel’, $this->post->ID); ?>” this works both in the Article Display Wiew M2 and when using the Block 4 in TD Composer. But as soon as I do an if query “<?php if( get_field(‘kontext-titel’) ): ?><?php the_field(‘kontext-titel’, $this->post->ID); ?><?php endif; ?>” it works only in the Article Display Wiew M2 but not in block 4. Here are the screenshots:
modified td_module_2.php: http://prntscr.com/mqh9nz
Article Display Wiew M2: http://s752582646.online.de/category/magazin/new-business
Block 4 in TD Composer: http://s752582646.online.de/magazin

Best regards
Eugen

Post count: 35449

Hi,

Now I understand, sorry I was thinking that you want only a different layout.
So if you remove the if condition and you let https://www.screencast.com/t/rXZpbihyrG9 this changes appear in block 4 ?
The code seams to be like in AFC documentation -> https://www.advancedcustomfields.com/resources/hiding-empty-fields/
Also please make sure that you clear all cache after you make some changes.

Thank you!

Post count: 11

Hi Calin,

that’s exactly what i have done – please have a look at the screenshot modified td_module_2.php: http://prntscr.com/mqh9nz

Best regards
Eugen

Post count: 35449

Hi,

Please make a test, remove the if condition save, clear all cache and see if now is appearing in block 4.

Thank you

Post count: 11

Hi Calin,

As shown in the screenshot of modified td_module_2.php (http://prntscr.com/mqh9nz), I display the value twice – with and without an “if-condition”.

Both variants work in the Article Display Wiew M2, but only the variant without if-condition works in block 4. But I need the if-condition in block 4. Please have a look at the links and screenshots in my previous comments.

Best regards
Eugen

Post count: 35449

Hi,

Please try this to code ->https://www.screencast.com/t/4XdRsJagi -> https://www.screencast.com/t/aaNeyo4qK
-> https://www.screencast.com/t/RcDIhRlIVZ
Or why not set the filed in if condition like this -> https://www.screencast.com/t/RamauH9Zl

Thank you.

Viewing 12 posts - 1 through 12 (of 12 total)
The forum ‘Newspaper’ is closed to new topics and replies.