Home Support Themes TaskHive Unable to find template file to make modifications

Unable to find template file to make modifications

  • Author
    Posts
  • m.ali.rashid

    Hey Team,
    I was struggling to find a template for this address
    https://beyondsport.co/listing/styrke-bootcamp/
    I found it’s using single.php file

    However, I want to modify the sidebar to add a new button
    https://pasteboard.co/JWqLKzX.png

    Please help
    Thanks

    ihor developer

    If this button has some unique value for each listing (e.g. URL) I recommend adding it as a listing attribute with custom display format, and assign it to the “Page (primary)” area https://hivepress.io/support/topic/is-it-possible-to-add-a-button-on-this-area/#post-12578

    ThomasB

    Hi Ihor. Me and Muhammad are on the same team, and we appreciate your generous help so far 🙂

    This is actually not what we are looking for, but we are about to make custom modifications and features to our site – so not just editing the attributes or making small adjustments. So we need to know which files we should access in order to implement our own features and change the site to our specific needs – or if you can give some guides in terms of what to do that would also be great help. We are skilled in software engineering, but not the wordpress setup – so we “just” need to know how to get started.

    Hope you can help us out! Btw, hope your tests with the booking extension are going just fine, looking forward to seeing it 🙂

    Thanks!

    Thomas

    ihor developer

    @ThomasB There are 2 ways to customize the HivePress templates:

    1. For adding custom content or layout changes, you can use “hivepress/v1/templates/…” filters. HivePress templates are built as arrays of blocks (to ensure future integration with Gutenberg), you can check sample code snippets in other topics https://hivepress.io/support/search/hivepress%2Fv1%2Ftemplates/

    2. For overriding some templates parts, you can copy any template from hivepress/templates (or any extension/templates) folder and paste it to the child theme’s “hivepress” subdolder (keeping the same path). Then the copied file will have a higher priority and will be loaded by HivePress first, so you can easily customize it. It works similarly to WooCommerce templates https://docs.woocommerce.com/document/template-structure/

    Hope this helps. I also plan to record a few video tutorials about customizing HivePress (the first one will be about the template customizations).

    m.ali.rashid

    Thanks, @ihor.
    Thanks, @ThomasB for clearing up my question.

    I am going through the templates again looking at all the ‘Arrays of Blocks’. I came across a file in
    includes/components/class-theme.php

    Can you suggest a plugin, a file, or a block of code that is responsible for the ‘Book’ button?
    I want to add another button “Monthly Book” beside this button.

    I have created a child theme. But I am not sure about what files to copy to it and modify.
    Please Guide

    Thanks

    ihor developer

    @m.ali.rashid Please try using this code snippet if you mean inserting some custom content into the listing sidebar:

    add_filter(
    	'hivepress/v1/templates/listing_view_page',
    	function( $template ) {
    		return hivepress()->helper->merge_trees(
    			$template,
    			[
    				'blocks' => [
    					'page_sidebar' => [
    						'blocks' => [
    							'my_custom_content' => [
    								'type'    => 'content',
    								'content' => 'custom content here',
    								'_order'  => 123,
    							],
    						],
    					],
    				],
    			]
    		);
    	},
    	1000
    );

    You can add it via the Code Snippets plugin, or to the child theme’s functions.php file.

    m.ali.rashid

    Hey @ihor
    I can’t thank you enough for this code snippet. This really cleared things up. Now I know what you meant by ‘AN ARRAY OF BLOCKS’.
    I have some experience developing WordPress websites. But I am new to the BLOCK ARRAY. I stopped working with WordPress and moved on to React JS in 2018. I have seen documentation on Guttenberg Blocks, but can you suggest good Documentation or a Tutorial where I can learn to create or modify Blocks.

    Thanks

    ihor developer

    You can find some info here https://developer.wordpress.org/block-editor/reference-guides/block-api/block-templates/ but Gutenberg API is a bit different, HivePress has its own API for this. You can check how templates are built here https://github.com/hivepress/hivepress/blob/master/includes/templates/class-listing-view-block.php There’s an array of blocks that you can override (add/unset blocks) via “hivepress/v1/templates/listing_view_block” filter. Any template can be overridden this way https://github.com/hivepress/hivepress/tree/master/includes/templates

    I’ll also create a video tutorial about customizing templates as soon as possible https://www.youtube.com/c/HivePress

    m.ali.rashid

    @ihor
    Thanks for the info. I’ll go through the templates and see if I can connect the dots
    Looking forward to that video tutorial.
    Thanks

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

You must be logged in to reply to this topic.