Adding 2 lines of text to vendors presentation

Adding 2 lines of text to the vendors profile. Something like this → https://i.imgur.com/Fwr7Qpc.png

Please try this PHP snippet

add_filter(
	'hivepress/v1/templates/vendor_view_block/blocks',
	function ($blocks, $template){
		$vendor = $template->get_context('vendor');
		
		if($vendor && $vendor->get_description()){
			$description = $vendor->get_description();
			
			if ( strlen( $description ) > 60 ) {
				$description = substr( $description, 0, 60 ).'...';
			}
			
			$blocks = hivepress()->helper->merge_trees(
					[ 'blocks' => $blocks ],
					[
						'blocks' => [
							'vendor_content' => [
								'blocks' => [
									'custom_vendor_description' => [
										'type' => 'content',
										'content' => '<p>'.$description.'</p>',
										'_order' => 1000,
									],
								],
							],
						],
				]
				)['blocks'];
			
		}
		
		return $blocks;
	},
	1000,
	2
);
2 Likes

This works really good… thanks :slight_smile: - Just one question, how can I add an extra line? (3 lines of text instead of 2).

Please try this PHP snippet instead

add_filter(
	'hivepress/v1/templates/vendor_view_block/blocks',
	function ($blocks, $template){
		$vendor = $template->get_context('vendor');
		
		if($vendor && $vendor->get_description()){
			$description = $vendor->get_description();
			
			if ( strlen( $description ) > 80 ) {
				$description = substr( $description, 0, 80 ).'...';
			}
			
			$blocks = hivepress()->helper->merge_trees(
					[ 'blocks' => $blocks ],
					[
						'blocks' => [
							'vendor_content' => [
								'blocks' => [
									'custom_vendor_description' => [
										'type' => 'content',
										'content' => '<p>'.$description.'</p>',
										'_order' => 1000,
									],
								],
							],
						],
				]
				)['blocks'];
			
		}
		
		return $blocks;
	},
	1000,
	2
);

The design looks sort of broken. Can we do something about this? →

Unfortunately, there is no easy way to resolve the same height issue because listing content height may be different ( as it also depends on the title, attributes, rating, etc. ). Also, you could try these solutions: Can the box size(height) be fixed or set to the maximum for the row? | HivePress Support

Thats a very nice Solution.
Could we change this to work for the Listing Page with the Listings listed?

Please let me know if you mean some specific CSS snippet from the linked topic? The snippets in the linked topic are not really good because they hard-code the box height, this may cut off the content on different screen sizes.

No, i dont want to change the css.
I want to add a certain amount (e.g. 80 Chars) of the description in the boxes on the listings page.

The same as with the Vendor described above but instead vendors with listings.

So the following snippet for listings

1 Like

Please try this PHP snippet

add_filter(
	'hivepress/v1/templates/listing_view_block/blocks',
	function ($blocks, $template){
		$listing = $template->get_context('listing');
		
		if($listing && $listing->get_description()){
			$description = $listing->get_description();
			
			if ( strlen( $description ) > 80 ) {
				$description = substr( $description, 0, 80 ).'...';
			}
			
			$blocks = hivepress()->helper->merge_trees(
					[ 'blocks' => $blocks ],
					[
						'blocks' => [
							'listing_content' => [
								'blocks' => [
									'custom_listing_description' => [
										'type' => 'content',
										'content' => '<p>'.$description.'</p>',
										'_order' => 1000,
									],
								],
							],
						],
				]
				)['blocks'];
			
		}
		
		return $blocks;
	},
	1000,
	2
);
2 Likes

Works perfekt! Thank you.
That are two nice snippets für the github gist :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.