blog-page.tsx
blog-detail.tsx
/blog/
.
blog
template in the base-theme
, you can navigate to the following directory structure.
blog-page
(blog-page.tsx
) template needs to be assigned to all the categories
and author
records in order to display the blog content correctly.
blog-page
template in the base theme contains a component that handles the listing of blog posts when the page assigned with the blog-page
.
blog-page
template in the base theme utilizes the ExpBlogListing
component, which receives the pageData
as a prop.
In the blog-listing
component, there are two important functions that need to be considered for manipulating how the blog data is fetched and displayed on the blog-page
template. These functions are responsible for fetching the blog data and c
Function | Description |
---|---|
getAPIQueryObject | This function is responsible for preparing an object for the API payload. It retrieves the data for the Post content model from the Experro Admin, including all the records related to posts. This function helps organize and structure the data in a format suitable for the API requests and subsequent usage in the application. To fetch data from the Experro Admin for the posts content model, including the related category and author information, you need to provide the necessary values in the query object. This allows you to retrieve the desired data from the specified content model, along with its associated category and author data. realtionField : This key, when provided with a specific value, instructs the query to fetch the data of the content model along with the related data from other content models that are associated with it. This allows you to retrieve the interconnected data and access the related content model’s data within the main content model’s data. Example, In the code snippet above, we are fetching the data of the posts content model. Additionally, we want to retrieve the data of the category content model and the author content model, which are related to the post records. This allows us to access and include the related data of the category and author content models when fetching the “post” data. relationField:'categories_exp_rel,author_exp_rel' relationFieldData: The relationFieldData key allows you to specify the fields of the related content models that you want to retrieve. By providing the desired field names in the relationFieldData key, you can fetch the specific data from the related content models that are associated with the posts content model. Example, To retrieve the page_slug and title fields for the related content model associated with the posts record, specify those fields in the query’s relationFieldData key for the related content model (related_content_model ).relationFieldDataToQuery: 'page_slug,title' |
getFilterString | The Blog-page template is designed to be assigned to records of content models such as Categories, Author, and the main Blog Page. The Blog-page record itself is created in the web-pages content model with a page-slug value of /blog/ . In the getAPIQueryObject function, there is a condition that distinguishes whether it is a main Blog-page or not. In the case of a other page, we need to fetch and display the posts that belong to the specified category or author.To specify whether the page is related to the categories content model or the author content model from pageData?.content_model_internal_name , we add an additional key to the apiData object called filter . This filter key contains information about the content model type and the content_model_data_id . It uses the category_exp_rel value when it is related to the categories content model. You can refer to the getFilterString function to understand more about how this filter string is constructed. |
For Blog-Detail page, template is already created in the the base theme, you need to use a template namedBlog-Detail Page
blog-detail.tsx
. This template should be assigned to the records of the posts
content model in the Experro Admin panel. This assignment will ensure that the blog-detail
template is used to render the individual blog post pages.
For a better understanding of the implementation details, you can refer to the code in the base theme template directory. The code will provide more insights into how the Blog
functionality is implemented.