{"tid":4164,"uid":3602,"cid":16,"mainPid":29447,"title":"Using page fields in widgets","slug":"4164/using-page-fields-in-widgets","timestamp":1428147352811,"lastposttime":1428362145743,"postcount":8,"viewcount":4724,"teaserPid":29659,"upvotes":0,"downvotes":0,"postercount":2,"tags":[{"value":"fields","valueEscaped":"fields","valueEncoded":"fields","class":"fields"},{"value":"widget","valueEscaped":"widget","valueEncoded":"widget","class":"widget"}],"deleted":0,"locked":0,"pinned":0,"pinExpiry":0,"deleterUid":0,"titleRaw":"Using page fields in widgets","timestampISO":"2015-04-04T11:35:52.811Z","scheduled":false,"lastposttimeISO":"2015-04-06T23:15:45.743Z","pinExpiryISO":"","votes":0,"thumbs":[],"posts":[{"timestamp":1428147352954,"votes":0,"content":"
In html code widget whether it is possible to use resource variables? Such as name, description. It would be very convenient! I'm pretty sure that will not be difficult to do this with the help of the plugin, but I still want make sure.
\n","tid":4164,"pid":29447,"uid":3602,"deleted":0,"upvotes":0,"downvotes":0,"deleterUid":0,"edited":0,"replies":{"hasMore":false,"hasSingleImmediateReply":false,"users":[],"text":"[[topic:one-reply-to-this-post]]","count":0},"bookmarks":0,"timestampISO":"2015-04-04T11:35:52.954Z","editedISO":"","index":0,"user":{"uid":3602,"username":"sergej-saveljev","fullname":"Cергей Савельев","userslug":"sergej-saveljev","reputation":12,"postcount":166,"topiccount":24,"picture":"","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1501524538903,"groupTitle":"3rd Party Developers","mutedUntil":0,"displayname":"Cергей Савельев","groupTitleArray":["3rd Party Developers"],"icon:text":"S","icon:bgColor":"#827717","lastonlineISO":"2017-07-31T18:08:58.903Z","banned_until":0,"banned_until_readable":"Not Banned","muted":false,"selectedGroups":[{"name":"3rd Party Developers","slug":"3rd-party-developers","labelColor":"#ffffff","textColor":"#000000","icon":"fa-cogs","userTitle":"Plugin & Theme Dev"}],"custom_profile_info":[]},"editor":null,"bookmarked":false,"upvoted":false,"downvoted":false,"selfPost":false,"events":[],"topicOwnerPost":true,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"editor":{"uid":3602,"username":"sergej-saveljev","userslug":"sergej-saveljev","displayname":"Cергей Савельев"},"timestamp":1428329460221,"votes":0,"content":"It would be desirable to be able to indicate the field values in widgets, for example:
\n<h1>\\{name\\}<h1>\n<p>\\{description\\}</p>\n
\n","tid":4164,"pid":29611,"edited":1428329544749,"uid":3602,"deleted":0,"upvotes":0,"downvotes":0,"deleterUid":0,"replies":{"hasMore":false,"hasSingleImmediateReply":false,"users":[],"text":"[[topic:one-reply-to-this-post]]","count":0},"bookmarks":0,"timestampISO":"2015-04-06T14:11:00.221Z","editedISO":"2015-04-06T14:12:24.749Z","index":1,"user":{"uid":3602,"username":"sergej-saveljev","fullname":"Cергей Савельев","userslug":"sergej-saveljev","reputation":12,"postcount":166,"topiccount":24,"picture":"","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1501524538903,"groupTitle":"3rd Party Developers","mutedUntil":0,"displayname":"Cергей Савельев","groupTitleArray":["3rd Party Developers"],"icon:text":"S","icon:bgColor":"#827717","lastonlineISO":"2017-07-31T18:08:58.903Z","banned_until":0,"banned_until_readable":"Not Banned","muted":false,"selectedGroups":[{"name":"3rd Party Developers","slug":"3rd-party-developers","labelColor":"#ffffff","textColor":"#000000","icon":"fa-cogs","userTitle":"Plugin & Theme Dev"}],"custom_profile_info":[]},"bookmarked":false,"upvoted":false,"downvoted":false,"selfPost":false,"events":[],"topicOwnerPost":true,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"editor":{"uid":970,"username":"a_5mith","userslug":"a_5mith","displayname":"a_5mith"},"timestamp":1428359029860,"votes":1,"content":"Do you mean the template variables? Like for example {{version}}
and {{socketioTransports}}
You'll have to quote my posts to see what I've actually typed.
\n","tid":4164,"pid":29649,"edited":1428359096529,"uid":970,"upvotes":1,"replies":{"hasMore":false,"hasSingleImmediateReply":true,"users":[{"uid":3602,"username":"sergej-saveljev","userslug":"sergej-saveljev","picture":"","fullname":"Cергей Савельев","displayname":"Cергей Савельев","icon:text":"S","icon:bgColor":"#827717"}],"text":"[[topic:one-reply-to-this-post]]","count":1,"timestampISO":"2015-04-06T22:30:15.808Z"},"deleted":0,"downvotes":0,"deleterUid":0,"bookmarks":0,"timestampISO":"2015-04-06T22:23:49.860Z","editedISO":"2015-04-06T22:24:56.529Z","index":2,"user":{"uid":970,"username":"a_5mith","userslug":"a_5mith","reputation":1082,"postcount":3136,"topiccount":184,"picture":null,"signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1482277364236,"groupTitle":null,"mutedUntil":0,"displayname":"a_5mith","groupTitleArray":[],"icon:text":"A","icon:bgColor":"#1b5e20","lastonlineISO":"2016-12-20T23:42:44.236Z","banned_until":0,"banned_until_readable":"Not Banned","muted":false,"selectedGroups":[],"custom_profile_info":[]},"bookmarked":false,"upvoted":false,"downvoted":false,"selfPost":false,"events":[],"topicOwnerPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"pid":29651,"uid":3602,"tid":4164,"content":"@a_5mith yes! )
\n","timestamp":1428359415808,"votes":0,"toPid":29649,"deleted":0,"upvotes":0,"downvotes":0,"deleterUid":0,"edited":0,"replies":{"hasMore":false,"hasSingleImmediateReply":false,"users":[],"text":"[[topic:one-reply-to-this-post]]","count":0},"bookmarks":0,"timestampISO":"2015-04-06T22:30:15.808Z","editedISO":"","index":3,"parent":{"username":"a_5mith","displayname":"a_5mith"},"user":{"uid":3602,"username":"sergej-saveljev","fullname":"Cергей Савельев","userslug":"sergej-saveljev","reputation":12,"postcount":166,"topiccount":24,"picture":"","signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1501524538903,"groupTitle":"3rd Party Developers","mutedUntil":0,"displayname":"Cергей Савельев","groupTitleArray":["3rd Party Developers"],"icon:text":"S","icon:bgColor":"#827717","lastonlineISO":"2017-07-31T18:08:58.903Z","banned_until":0,"banned_until_readable":"Not Banned","muted":false,"selectedGroups":[{"name":"3rd Party Developers","slug":"3rd-party-developers","labelColor":"#ffffff","textColor":"#000000","icon":"fa-cogs","userTitle":"Plugin & Theme Dev"}],"custom_profile_info":[]},"editor":null,"bookmarked":false,"upvoted":false,"downvoted":false,"selfPost":false,"events":[],"topicOwnerPost":true,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"editor":{"uid":970,"username":"a_5mith","userslug":"a_5mith","displayname":"a_5mith"},"timestamp":1428359623795,"votes":1,"content":"As long as the information you want is in the API for that page, then yes, you can. You can do either the page you're on with single brackets, so this topic for example was started by {posts.editor.username} and is the {posts.pid}nd post made.
\nOr you can use two brackets per side to access anything from the config api. Which is found by going to https://community.nodebb.org/api/config/.
\nThe API for this topic is https://community.nodebb.org/api/topic/4164/using-page-fields-in-widgets, if you paste all of that into jsonlint.com, you will see the hierarchy.
\nSo look at posts, then user, then username, then look at what I typed, notice the full stops.
\nSo this will only work on the page the widget is being displayed on. So you can't for example add post information on the home page.
\nAlmost every page has an api, you access the data by adding /api/ immediately after your domain name, before the rest of the URL.
\n","tid":4164,"pid":29652,"edited":1428359786263,"uid":970,"upvotes":1,"replies":{"hasMore":false,"hasSingleImmediateReply":true,"users":[{"uid":3602,"username":"sergej-saveljev","userslug":"sergej-saveljev","picture":"","fullname":"Cергей Савельев","displayname":"Cергей Савельев","icon:text":"S","icon:bgColor":"#827717"}],"text":"[[topic:one-reply-to-this-post]]","count":1,"timestampISO":"2015-04-06T22:49:35.160Z"},"deleted":0,"downvotes":0,"deleterUid":0,"bookmarks":0,"timestampISO":"2015-04-06T22:33:43.795Z","editedISO":"2015-04-06T22:36:26.263Z","index":4,"user":{"uid":970,"username":"a_5mith","userslug":"a_5mith","reputation":1082,"postcount":3136,"topiccount":184,"picture":null,"signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1482277364236,"groupTitle":null,"mutedUntil":0,"displayname":"a_5mith","groupTitleArray":[],"icon:text":"A","icon:bgColor":"#1b5e20","lastonlineISO":"2016-12-20T23:42:44.236Z","banned_until":0,"banned_until_readable":"Not Banned","muted":false,"selectedGroups":[],"custom_profile_info":[]},"bookmarked":false,"upvoted":false,"downvoted":false,"selfPost":false,"events":[],"topicOwnerPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true},{"pid":29655,"uid":3602,"tid":4164,"content":"@a_5mith \\{posts.editor.username\\}
not work in widgets
@sergej-saveljev said:
\n\n\n@a_5mith
\n\\{posts.editor.username\\}
not work in widgets
Is that available in the api on the page you're viewing the widget on. I'm pretty sure that's how it works. Pinging @psychobunny as it's his templates.js.
\n","tid":4164,"toPid":29655,"pid":29659,"uid":970,"deleted":0,"upvotes":0,"downvotes":0,"deleterUid":0,"edited":0,"replies":{"hasMore":false,"hasSingleImmediateReply":false,"users":[],"text":"[[topic:one-reply-to-this-post]]","count":0},"bookmarks":0,"timestampISO":"2015-04-06T23:15:45.743Z","editedISO":"","index":7,"parent":{"username":"sergej-saveljev","displayname":"Cергей Савельев"},"user":{"uid":970,"username":"a_5mith","userslug":"a_5mith","reputation":1082,"postcount":3136,"topiccount":184,"picture":null,"signature":"","banned":false,"banned:expire":0,"status":"offline","lastonline":1482277364236,"groupTitle":null,"mutedUntil":0,"displayname":"a_5mith","groupTitleArray":[],"icon:text":"A","icon:bgColor":"#1b5e20","lastonlineISO":"2016-12-20T23:42:44.236Z","banned_until":0,"banned_until_readable":"Not Banned","muted":false,"selectedGroups":[],"custom_profile_info":[]},"editor":null,"bookmarked":false,"upvoted":false,"downvoted":false,"selfPost":false,"events":[],"topicOwnerPost":false,"display_edit_tools":false,"display_delete_tools":false,"display_moderator_tools":false,"display_move_tools":false,"display_post_menu":true}],"events":[],"category":{"cid":16,"name":"Technical Support","description":"Need help with installing or configuring NodeBB? Look here.","icon":"fa-exclamation-triangle","bgColor":"#6c7d3f","color":"#ffffff","slug":"16/technical-support","parentCid":0,"topic_count":4532,"post_count":25197,"disabled":0,"order":6,"link":"","numRecentReplies":1,"class":"col-md-3 col-xs-12","imageClass":"auto","descriptionParsed":"Need help with installing or configuring NodeBB? Look here.
\n","subCategoriesPerPage":10,"minTags":0,"maxTags":5,"postQueue":1,"isSection":0,"totalPostCount":25197,"totalTopicCount":4532},"tagWhitelist":[],"minTags":0,"maxTags":5,"thread_tools":[{"class":"toggleQuestionStatus","title":"[[qanda:thread.tool.as_question]]","icon":"fa-question-circle"}],"isFollowing":false,"isNotFollowing":true,"isIgnoring":false,"bookmark":null,"postSharing":[{"id":"facebook","name":"Facebook","class":"fa-brands fa-facebook","activated":true},{"id":"twitter","name":"X (Twitter)","class":"fa-brands fa-x-twitter","activated":true},{"id":"whatsapp","name":"Whatsapp","class":"fa-brands fa-whatsapp","activated":true},{"id":"telegram","name":"Telegram","class":"fa-brands fa-telegram","activated":true},{"id":"linkedin","name":"LinkedIn","class":"fa-brands fa-linkedin","activated":true}],"deleter":null,"merger":null,"forker":null,"related":[],"unreplied":false,"icons":[],"privileges":{"topics:reply":false,"topics:read":true,"topics:schedule":false,"topics:tag":false,"topics:delete":false,"posts:edit":false,"posts:history":false,"posts:upvote":false,"posts:downvote":false,"posts:delete":false,"posts:view_deleted":false,"read":true,"purge":false,"view_thread_tools":false,"editable":false,"deletable":false,"view_deleted":false,"view_scheduled":false,"isAdminOrMod":false,"disabled":0,"tid":"4164","uid":-1},"topicStaleDays":60,"reputation:disabled":0,"downvote:disabled":0,"feeds:disableRSS":0,"signatures:hideDuplicates":0,"bookmarkThreshold":5,"necroThreshold":7,"postEditDuration":0,"postDeleteDuration":0,"scrollToMyPost":false,"updateUrlWithPostIndex":false,"allowMultipleBadges":true,"privateUploads":false,"showPostPreviewsOnHover":true,"sortOptionLabel":"[[topic:oldest-to-newest]]","rssFeedUrl":"/topic/4164.rss","postIndex":1,"breadcrumbs":[{"text":"[[global:home]]","url":"https://community.nodebb.org"},{"text":"Technical Support","url":"https://community.nodebb.org/category/16/technical-support","cid":16},{"text":"Using page fields in widgets"}],"author":{"username":"sergej-saveljev","userslug":"sergej-saveljev","uid":3602,"displayname":"Cергей Савельев"},"pagination":{"prev":{"page":1,"active":false},"next":{"page":1,"active":false},"first":{"page":1,"active":true},"last":{"page":1,"active":true},"rel":[],"pages":[],"currentPage":1,"pageCount":1},"loggedIn":false,"loggedInUser":{"uid":0,"username":"[[global:guest]]","picture":"","icon:text":"?","icon:bgColor":"#aaa"},"relative_path":"","template":{"name":"topic","topic":true},"url":"/topic/4164/using-page-fields-in-widgets","bodyClass":"page-topic page-topic-4164 page-topic-using-page-fields-in-widgets template-topic page-topic-category-16 page-topic-category-technical-support parent-category-16 page-status-200 theme-harmony user-guest","browsingUsers":true,"_header":{"tags":{"meta":[{"name":"viewport","content":"width=device-width, initial-scale=1.0"},{"name":"content-type","content":"text/html; charset=UTF-8","noEscape":true},{"name":"apple-mobile-web-app-capable","content":"yes"},{"name":"mobile-web-app-capable","content":"yes"},{"property":"og:site_name","content":"NodeBB Community"},{"name":"msapplication-badge","content":"frequency=30; polling-uri=https://community.nodebb.org/sitemap.xml","noEscape":true},{"name":"theme-color","content":"#0471ff"},{"name":"keywords","content":"nodebb,forum,community,discussion,javascript,nodejs,mongodb,redis,websockets"},{"name":"msapplication-square150x150logo","content":"/assets/uploads/system/site-logo.png","noEscape":true},{"name":"title","content":"Using page fields in widgets"},{"property":"og:title","content":"Using page fields in widgets"},{"property":"og:type","content":"article"},{"property":"article:published_time","content":"2015-04-04T11:35:52.811Z"},{"property":"article:modified_time","content":"2015-04-06T23:15:45.743Z"},{"property":"article:section","content":"Technical Support"},{"name":"description","content":"In html code widget whether it is possible to use resource variables? Such as name, description. It would be very convenient! I'm pretty sure that will not b..."},{"property":"og:description","content":"In html code widget whether it is possible to use resource variables? Such as name, description. It would be very convenient! I'm pretty sure that will not b..."},{"property":"og:image","content":"https://community.nodebb.org/assets/uploads/system/site-logo.png","noEscape":true},{"property":"og:image:url","content":"https://community.nodebb.org/assets/uploads/system/site-logo.png","noEscape":true},{"property":"og:image:width","content":"376"},{"property":"og:image:height","content":"132"},{"content":"https://community.nodebb.org/api/topic/4164/using-page-fields-in-widgets","property":"og:url"}],"link":[{"rel":"icon","type":"image/x-icon","href":"/assets/uploads/system/favicon.ico?v=ehq9o4pbd8q"},{"rel":"manifest","href":"/manifest.webmanifest","crossorigin":"use-credentials"},{"rel":"search","type":"application/opensearchdescription+xml","title":"NodeBB Community","href":"/osd.xml"},{"rel":"apple-touch-icon","href":"/assets/uploads/system/touchicon-orig.png"},{"rel":"icon","sizes":"36x36","href":"/assets/uploads/system/touchicon-36.png"},{"rel":"icon","sizes":"48x48","href":"/assets/uploads/system/touchicon-48.png"},{"rel":"icon","sizes":"72x72","href":"/assets/uploads/system/touchicon-72.png"},{"rel":"icon","sizes":"96x96","href":"/assets/uploads/system/touchicon-96.png"},{"rel":"icon","sizes":"144x144","href":"/assets/uploads/system/touchicon-144.png"},{"rel":"icon","sizes":"192x192","href":"/assets/uploads/system/touchicon-192.png"},{"rel":"prefetch stylesheet","type":"","href":"/assets/plugins/nodebb-plugin-markdown/styles/github.css"},{"rel":"prefetch","href":"/assets/language/en-GB/markdown.json?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/src/modules/composer.js?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/src/modules/composer/uploads.js?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/src/modules/composer/drafts.js?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/src/modules/composer/tags.js?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/src/modules/composer/categoryList.js?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/src/modules/composer/resize.js?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/src/modules/composer/autocomplete.js?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/templates/composer.tpl?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/language/en-GB/topic.json?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/language/en-GB/modules.json?v=ehq9o4pbd8q"},{"rel":"prefetch","href":"/assets/language/en-GB/tags.json?v=ehq9o4pbd8q"},{"rel":"stylesheet","href":"https://community.nodebb.org/assets/plugins/nodebb-plugin-emoji/emoji/styles.css?v=ehq9o4pbd8q"},{"rel":"canonical","href":"https://community.nodebb.org/topic/4164/using-page-fields-in-widgets","noEscape":true},{"rel":"alternate","type":"application/rss+xml","href":"/topic/4164.rss"},{"rel":"up","href":"https://community.nodebb.org/category/16/technical-support"},{"rel":"author","href":"https://community.nodebb.org/user/sergej-saveljev"}]}},"widgets":{"footer":[{"html":"\r\n\r\n