I hate the restrictive templates for the blog post pages and recent post feeds. Would it be possible to create my own blog data set and linked dynamic pages instead? The only issue would be how would you manage subscribers and notify people of new posts.
I have already copied the blog dataset into a new dataset which is now read-write only, I have created a repeater that would be the recent posts for the home page, I have designed my own dynamic page that will be the blog post page, I just need to figure out how to link the repeater to the blog post page. When I click on the repeater button it doesn't take to the dynamic blog post page.
*I have tried to create my own custom blog page using Corvid by taking an example code what's been suggested. The code was fine other than the valid selector. There is no way to check the dataset ID from the blog data. I've already started creating my own separate dataset of blog posts so that I can implement the first method, so don't want to try to get into coding and do this way now.
Appreciate any help!
-Josie
Hi @Rafal Zacharevič ,
Do you know if this works in Editor X? And can I put more information like author nickname, author profile photo, likes and views? Cn't figure out how to make it work
Thank you very much for your contribution ! it works very well now!
Hello @sear02,
I've fixed your code.
When following the instructions from https://www.wix.com/corvid/example/custom-post-page
You forgot to create a data.js code in your backend. I've done that for you.
And when you created a reference field and called it "Ref", this part of the code:
let postDataFromCollection = await wixData.query("PostExtraData2")
.eq("post", post._id)
.find()
Should've looked like this:
let postDataFromCollection = await wixData.query("PostExtraData2")
.eq("ref", post._id)
.find()
If you have any more questions, you can always email me.
I've added you as contributor on the website, you should receive a notification.
Hey @sear02,
You can either add me as a contributor (my email: rafalz@wix.com) or you can email me the username or the email of the account where the site is stored.
Cheers!
Hi @Rafal Zacharevič ,
Thank you for your quick reply !
It still doesn't work... I have the same error:
To make it simple, I created a new dataset collection (PostExtraData2) :
As you told me, I created a reference column which uses the title of my blog posts (I didn't have the choice of the ref data, it is automatic).
I adjust the code by putting "PostExtraData2" :
import wixData from 'wix-data'; let currentPost $w.onReady(function () { $w("#post1").getPost().then(async post => { currentPost = await loadPostExtraData(post) assignPostDataToUIElements() }); }) async function loadPostExtraData(post) { let postDataFromCollection = await wixData.query("PostExtraData2") .eq("post", post.title) .find() postDataFromCollection = postDataFromCollection.items[0] return mergePostData(post, postDataFromCollection) } async function mergePostData(post, ExtraData) { return Object.assign({}, post, ExtraData) } function assignPostDataToUIElements() { $w("#postTitle").text = currentPost.title $w("#postHeaderStrip").background.src = currentPost.coverImage $w("#postHeaderStrip").show("fade") $w("#text30").text = currentPost.sector }
We are working on my new company's website with a contractor who has no dev skills, so I try to figure out by myself how to set-up specific feature that we will need when the website will be live. I'm working on a template provided by Wix which is not online, how can I give you access to this website ?
Hello @sear02,
The error that you get means that currentPost.sector has no value.
I think the error might not be code related.
When you have your collection ExtraPostData, you need to have a reference column to posts inside that collection, so that every sector element has an assigned post.
This way, when you're initiating this part of the code:
let postDataFromCollection = await wixData.query("PostExtraData")
.eq("post", post._id)
.find()
It finds which sector item belongs to which post.
Tell me how it goes or if you're still having trouble, feel free to share with me the URL of your website and I'll have a look at it myself.
Hi Rafal,
Based on the link you sent, I succeeded in setting-up the customized strip and title, it works very well!
Nonetheless, I'm still not able to display extra data that I store in another dataset collection :
name of the dataset collection : PostExtraData
name of the extra data I want to display: sector
Here's the code I set-up in the console, do you know by any chance what's wrong with it ? I feel like the merge of the 2 dataset collection doesn't work but I don't know why...
import wixData from 'wix-data'; let currentPost $w.onReady(function () { $w("#post1").getPost().then(async post => { currentPost = await loadPostExtraData(post) assignPostDataToUIElements() }); }) async function loadPostExtraData(post) { let postDataFromCollection = await wixData.query("PostExtraData") .eq("post", post._id) .find() postDataFromCollection = postDataFromCollection.items[0] return mergePostData(post, postDataFromCollection) } async function mergePostData(post, ExtraData) { return Object.assign({}, post, ExtraData) } function assignPostDataToUIElements() { $w("#postTitle").text = currentPost.title $w("#postHeaderStrip").background.src = currentPost.coverImage $w("#postHeaderStrip").show("fade") $w("#text30").text = currentPost.sector }
Hey @Josie Collins,
I understand what you mean. Then it seems the only way to connect elements with the dataset is through the code. This page here shows a good example of how's that done and also lets you see and edit it yourself: https://www.wix.com/corvid/example/custom-post-page
Let me know if you have any more questions!
Hi Rafal,
Thank you for taking the time to help me, I really appreciate it!
I think I was overcomplicating things way too much and not understanding how far I could customize the templates!
The only issue I am having now is that placeholder header image and title I added doesn't match the blog post.
I have this header on all the posts:
The image and title are connected to the correct blog post dataset just as you showed me.
For every post I open, it shows only my first blog posts' title and cover image which doesn't match.
Hope this makes sense.
Hello @Josie Collins ,
Creating your own custom feed with the new Wix Blog is really easy, allow me to show you. After investigating your site, I'll more or less try to show an example that will be similar to what you're trying to do.
First, let's start with the easy part, the Recent Post list. For that, you'll need 2 things, a repeater (customized the way you want) and a dataset that has the "Posts" collection:
Now, move on to your repeater and connect the Data:
Here's how I connected each element:
You may notice the text is on there twice but that's because I have 2 text elements. Every time you select an element from the Repeater toolbar, that element is highlighted on the repeater so you know with which one you're working.
After everything is connected, we can see the results in the preview:
Now let's continue to the Post Page.
From what you said, I understand you tried creating a post page following this article: https://www.wix.com/corvid/example/custom-post-page.
However, there's a similar way of building a post page, like we did with the recent posts feed, without the need of coding. Here's how to do it:
First, I suggest turning off all the display features that you will be showing differently, for instance, I'll make my Title and image above the post so I won't be needing them inside the post itself:
Now I create a placeholder for those elements:
All that's left is to create a Post dataset and connect the elements as done previously:
Let's hit preview and see how it turned out:
Now, we see 2 images, because 1 image is in the content. To fix this problem, simply delete the image from the post itself and upload it as a cover image:
And the end result will look something like this:
Sorry if this turned out to be a long post but I hope I was able to explain all the possible customization possibilities.
If you have any questions, be sure to ask and I will gladly answer them!