• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

custom post data show in editor

Scheduled Pinned Locked Moved Solved Plugin Development
4 Posts 2 Posters 732 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • am1cableA Offline
    am1cableA Offline
    am1cable
    wrote on last edited by am1cable
    #1

    I've got some custom fields that I have working in my composer, but I'd like to be able to show the data that was submitted when editing posts. I tried passing it in as templateData when composer.build is called, but it only seems to be called when you have the composer as a separate route, which I don't want.

    tl;dr I have data in postData that I want to show/be editable by users while editing their posts, how do I get it into composerData? thanks!

    1 Reply Last reply
    0
  • am1cableA Offline
    am1cableA Offline
    am1cable
    wrote on last edited by
    #2

    Is this not a thing that's possible? It feels pretty basic.

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #3

    It is possible using two hooks.

    Server side you need "filter:composer.push"

    myPlugin.onComposerPush = function (hookData, callback) {
    	// called when composer is opened to edit a post
    	posts.getPostField(hookData.pid, 'myCustomField', function (err, customField) {
    		if (err) {
    			return callback(err);
    		}
    		hookData.myCustomField = customField;
    		callback(null, hookData);
    	});
    };
    

    Client side you need "filter:composer.create"

    $(window).on('filter:composer.create', function (ev, data) {
    	data.createData.myCustomField = parseInt(data.postData.myCustomField, 10) === 1;
    });
    

    After adding those two hooks myCustomField will be available to use in the the composer template.

    1 Reply Last reply
    1
  • am1cableA Offline
    am1cableA Offline
    am1cable
    wrote on last edited by
    #4

    excellent! thank you very much

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development