How can I modify the DBsearch results page?
-
Hi,
I'm going to change something on dbsearch results page:
-
How can I add topic's thumb in there?
-
How can I remove this shortcode?
[embed-iframe] [{"name": "Video 1", "link": "https://www.youtube.com/embed/1cr_uPGOCeE?si=dc0ygHELF9Opgf9X"}]
-
-
S support@community.nodebb.org shared this topic
-
Anyone have idea for this case?
-
You need to add the thumbs into the results using a hook from
src/search.js
'filter:search.contentGetResult'
should work, you can also replace the embed shortcode in the same hooks.To display the thumbs in the page you need to modify the template at https://github.com/NodeBB/nodebb-theme-harmony/blob/main/templates/partials/search-results.tpl and replace html with your own and use the thumbnails.
-
@baris i finished for remove shortcode, but I don't see thumb when i debug data value
filterSearchContentGetResult: async function (data) { const posts = data.result.posts; for (let post of posts) { post.content = post.content.replace(/^\[embed-iframe\].*$/gm, ''); } return data; },
This is data value:
{ pid: 41238, tid: 41238, content: '<p dir="auto">content <br />\n' + '[embed-iframe] [{"name": "Video 1", "link": "https://www.youtube.com/embed/1cr_uPGOCeE?si=dc0ygHELF9Opgf9X"}]</p>\n', uid: 1, timestamp: 1735617649489, deleted: false, upvotes: 0, downvotes: 0, replies: 0, handle: undefined, votes: 0, timestampISO: '2024-12-31T04:00:49.489Z', user: { uid: 1, username: 'user', userslug: 'user', picture: null, status: 'online', uploadedpicture: undefined, lastonline: undefined, fullname: undefined, displayname: 'user', 'icon:bgColor': '#673ab7', 'icon:text': 'A', lastonlineISO: undefined }, topic: { uid: 1, tid: 41238, title: 'embed logs', cid: 2, tags: [Array], slug: '41238/embed-logs', deleted: 0, scheduled: false, postcount: 1, mainPid: 41238, teaserPid: null, timestamp: 1735617649441, titleRaw: 'embed logs', timestampISO: '2024-12-31T04:00:49.441Z' }, category: { cid: 2, name: 'General Discussion 5', icon: 'fa-comments-o', slug: '2/general-discussion-5', parentCid: 0, bgColor: '#59b3d0', color: '#ffffff', backgroundImage: '', imageClass: 'cover' }, isMainPost: true },
-
You need to load it yourself using the
topic
values and the methodthumbs.load