Home User profile
tagDiv Member
This user did not write anything. So we are just showing here some random text to make the profile page look nice :)
garyjones
tagDiv Member

Hi Simion

I meant to sat I hope the final post is OK.

Best

G

garyjones
tagDiv Member

Hi Simion

I posted here https://forum.tagdiv.com/topic/code-share-different-content-at-the-same-time-from-block-10/#post-308876 but it didn’t accept the html for my table and I can’t edit it. Can you pull it down and I will report the table as text,

Sorry about this.

G

garyjones
tagDiv Member

Hi Simion,

I hope you are well.

I have made some changes to the previous td_module_9 php I sent you.

Rather than hard coding the If and ElseIf statements with the category and tags as before, the If statement now calls a post_type variable. This is basically an ACF custom field, with two options, to which some of the other ACF fields are conditionally tied – I also changed the ElseIf to an Else.

In addition I have integrated the code with the module 9 default div classes and added a couple including a couple span classes. This now means each field sits within a separate CSS element I can style. The code is also now shorter as you will see –

<?php

class td_module_9 extends td_module {

function __construct($post, $module_atts = array()) {
//run the parrent constructor
parent::__construct($post, $module_atts);
}

function render() {
ob_start();
$title_length = $this->get_shortcode_att('m9_tl');
$modified_date = $this->get_shortcode_att('show_modified_date');

$hb1 = in_category(array('News','Features','Tech'), $this->post->ID );
$hb2 = in_category( array('Research'), $this->post->ID );
$hb3 = has_tag(array( 'aged care', 'anxiety/stress', 'autism', 'cognitive', 'Dementia', "Parkinson's", 'sleep' , 'well-being' ), $this->post->ID);
$hb4 = get_field (post_type, $this->post->ID);

$link = get_field('media_outlet_url', $this->post->ID);
$media = get_field ('media_outlet', $this->post->ID);
$country = get_field ('country', $this->post->ID);
$publicationdate = get_field ('publication_date', $this->post->ID);

?>

<div class="<?php echo $this->get_module_classes();?>">

<div class="item-details">
post->ID); ?>" rel="bookmark" title="<?php echo get_the_title( $this->post->ID );//$title; ?>"><?php echo get_the_title( $this->post->ID ); //$title; ?>

<div class ="news_headline">
</div>

<?php if (td_util::get_option('tds_category_module_9') == 'yes') { echo $this->get_category(); }?>

<div class="td-module-meta-info">

<div class="media_date">
<span class="td-post-author-name">
<?php if ($hb4 == "News etc"){
echo "{$media}";
}else{
echo $media;
}?>
<span>-</span> </span>
<span class="td-post-date">
<time class="entry-date updated td-module-date"><?php echo $publicationdate; ?></time></span>
</div>

<div class="td-post-content">
<?php if ($hb4 == "News etc"){
echo $country;
}else{
echo $this->get_the_tags();
}?>

</div>

</div>

</div>

<?php echo $this->get_quotes_on_blocks();?>

</div>
<?php return ob_get_clean();
}
}

I still have to work on the CSS, You will notice some of the div names don’t make sense when compared to the fields they contain and some of my previous CSS is now redundant so it needs a tidy up.

I aim to get this done in the next couple days and will then put up a revised and instructional post for the community as promised.

If you spot anything I could improve or have any comments please do let me know.

Best Wishes

Gary

garyjones
tagDiv Member

Hi

Thanks again. Leave it with me. Hopefully, I will crack it today and put the new post up for the community.

Have a good day.

Best

G

garyjones
tagDiv Member

Hi Simion

I’m playing with making the country a tag, creating a separate Country taxonomy and then filtering against this – kind of makes sense, though I thought that extra alternative to a tag would scoop up another option and that also doesn’t solve the date issue so a container maybe the only option.

I tried the container div css code with article/section underneath it but it didn’t work.

I will keep trying but any insight you could give would be helpful.

Thanks for everything you have done.

Best

G

garyjones
tagDiv Member

Hi Simion

This is great thank you. Your idea about containers is great but I’m not sure how to pursue this. Any direction you could give would be great.

Thanks.

Best Wishes

Gary

garyjones
tagDiv Member

Hi Simeon

I trust you are well. I’ve done some more work.

Effectively what this does now is turn module 9 (I moved it from 8) into a kind of news, or other type, listing that is designed to feature aggregated content from other sites – so that when the headline is clicked it takes the viewer to another browser.

In the new version I have added Tags to the type where the content is driven by posts that have a certain category and tags attached (using this post) and deleting the Tag labelling from the td_module.php file.

When the content displayed is driven just by a category, I made the media outlet name a dynamic link that when cliked would also take the viewer to the main home page in a new window (as I am sure you know, this is a common feature of news aggregation services).

Whilst I have cracked the CSS a little I am still not strong enough to resolve all my needs. As an example I took the title field outside of the standard TagDiv placement to get the external URL to work. If I left it where it was it was adopting the a.link class from higher up but I couldnt see where. Obviously, this means any settings made to Block 10 style in the normal editor won’t work – which isn’t ideal.

Also, I think I over-complicated the CSS. My additions are –

/* Adds line under each story */
.td_block_10 .td_module_9 {text-align: left; border-bottom: 0.5px solid #d3d3d3; padding: 0 0 0.5em 0; margin: 0 0 0.5em 0;}

/* headline link details */
.item-details a:link {
font-family:Open Sans;
color:#000000;
font-size:13px;
font-weight:700;
}
a:hover {
color:#459fd3;
}
a:visited {
color:#336980;
}

/* Sets width of box header */
.td-pulldown-size {width: 100px;}

/*sets font style for news details */
.news_details {font-family:Open Sans;
color:#000000;
font-size:11px;
font-weight:600;
padding-bottom: 3px;
}

a:link {
font-family:Open Sans;
color:#000000;
font-size:11px;
font-weight:600;
}
a:visited {
color:#459fd3;
}

In this image you will see the two options along with the issues I can’t fix, https://prnt.sc/om3yp8,

Any help you can give with the CSS would be appreciated.

I am more than happy to then create a clean post for the community, with the code and an explanation of each ACF field etc – and reference the new post at the end of this chain.

I am just experimenting with design options across the entire site at the moment but if you go here, (p/w: he768ijKllmnhp). If you need admin access let me know.

Thanks in advance.

Best wishes

Gary

garyjones
tagDiv Member

Thanks Simion

Leave it with me and I will see if I can crack it.

garyjones
tagDiv Member

Hi Simion,

I have taken what you did and extended the functionality.

When added to a module it displays a list of relevant posts, with one set of ACF custom fields, if the block directory category filter is set to either ‘News’,’Features’ or’Tech’ – or it displays posts, featuring other custom fields, if the block directory category filter is set to ‘Research’ and the relevant posts are tagged with any of ‘aged care’, ‘anxiety/stress’, ‘autism’, ‘cognitive’, ‘Dementia’, “Parkinson’s”, ‘sleep’ or ‘well-being’.

******

<?php

$hb1 = in_category(
array(‘News’,’Features’,’Tech’),
$this->post->ID
);
$hb2 = in_category( array(‘Research’), $this->post->ID );
$hb3 = has_tag(
array( ‘aged care’, ‘anxiety/stress’, ‘autism’, ‘cognitive’, ‘Dementia’, “Parkinson’s”, ‘sleep’ , ‘well-being’ ),
$this->post->ID
);

if ( $hb1 )
{
the_field(‘media_outlet’, $this->post->ID);
the_field(‘media_outlet_url’, $this->post->ID);
the_field(‘published_date’, $this->post->ID);
}
else if ( $hb2 && $hb3 )
{
the_field(‘media_outlet’, $this->post->ID);
the_field(‘published_date’, $this->post->ID);
the_field(‘country’, $this->post->ID);
}
?>

******
I thought it might be worth sharing it with the community (btw, I have spent quite a lot of time today going through the support forum. A code snippet section would be useful).

In the TagDiv block editor I added the Class name “editorial_listing_block and tried to use this to apply different a different font family, font size, font weight and colour to each of the custom fields but it didn’t work. My CCS skills are very limited.

Could you give some advice as to how I achieve my desired CSS styling for the displayed field content?

Many Thanks.

Best

G

garyjones
tagDiv Member

Hi Simion,

Obviously I would like to apply formatting to this. Is it better to add a new Div Class to the main CSS style sheet or use the Newspaper custom CSS options?

If the latter could you provide me with an example that formats your Gadget field as an OpenSans font, 600 weight, bold etc?

I am not clear whether I create a new class in the CSS options box or overwrite a class using .TD_module_X {}

Thanks

G

garyjones
tagDiv Member

Fantastic! Thank you very much!

garyjones
tagDiv Member

Hi Simion

Thanks for clarifying.

Best

G

garyjones
tagDiv Member

Hi Simon

That is indeed great news and thanks for taking the suggestion on board. The proposed guide will absolutely blow open the creative possibilities, particularly for those who don’t have the coding skills to dig deep into the php and CSS to write new code from scratch.

Also, great news about the Child theme. I am running 9.7.2 so I presume the child theme will work with this, save the few quirks you mentioned.

Best

G

garyjones
tagDiv Member

Thanks

garyjones
tagDiv Member

Hi Calin

I have resolved this now by creating and adding new div classes.

Best

G

garyjones
tagDiv Member

Hi

Scrap my last message. I’ve sorted it

G

garyjones
tagDiv Member

Hi

Thanks. This article is a bit out of date as it references Child Themes. I can do the coding but would like to know which Flex Block 1 td_ php file contains the code that services the title display. Am going mad and can’t find it.

Best

G

garyjones
tagDiv Member

Hi Calin

I have restructured my ACF custom fields and have looked into your suggestion. As an example if I place the following code into the previous modules I mentioned, i.e. module 8 or 9, this sits appends an external URL (stored in a custom field) to the relevent post title –

<h3 class=”entry-title td-module-title”>post->ID); ?>” rel=”bookmark” title=”<?php echo get_the_title( $this->post->ID );//$title; ?>”><?php echo get_the_title( $this->post->ID ); //$title; ?></h3>

However, I can seem to get this to work with Flex Block 1.

Any help appreciated as always.

Best

G

garyjones
tagDiv Member

Hi mOrtyr

I also need this functionality but my limited coding skills mean I haven’t been able to get it to work.

Would you mind sharing your updated solution?

Thanks.

Best

G

garyjones
tagDiv Member

Hi Simon

Thanks for getting back. I’m now confused as to hoe I use Block 9/module 8 in this new scenario.

Do I simply create a td_block_textlist.php file by copying and renaming the existing .php file for block 9 and then drop the shortcode in under the API call? (both are above)

All help appreciated

Thanks.

Best

Gary

garyjones
tagDiv Member

Hi Calin

Thanks for getting back to me. I would indeed prefer to use Flex Blocks.

If you go here now, https://www.infowebpublishing.com/ you will see where I have got to with the Block 9/Module 8 combination but I can’t work out where to place the above custom php/CSS into a Flex Block. I think Flex 4 is the best option.

Any help would be appreciated. Happy to give you Admin access.

Have a good International Workers Day.

Best wishes

Gary

garyjones
tagDiv Member

Hi Calin

Apologies about the web site but it’s all sorted now. However, I am confused about the new Envato-compliant version of Newspaper 9.7.2 and the use of child themes.

Given I have modified module 8 and the corresponding CSS where does this now sit in terms if a child theme, as the related block/module includes has moved to a “legacy” folder within wp-content>plugins etc.

This seems to me that I cannot create a child and my customised block will be overwritten each time their is an update.

Is this the case? If so, how do you recommend getting around this?

Thanks

Best

Gary

garyjones
tagDiv Member

Great. Thanks.

Viewing 24 posts - 1 through 24 (of 24 total)