• 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

Inserting additional template data into composer template

Scheduled Pinned Locked Moved Unsolved Plugin Development
composercustomplugindevelopment
5 Posts 3 Posters 608 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.
  • E Offline
    E Offline
    erichbb
    wrote on last edited by
    #1

    Hi, I am customizing the default composer.

    To have a better understanding of how this templating system works, I am trying to add a new variable, similar to isTopicOrMain for a conditonal in the composer.tpl.

    I noticed that isTopicOrMain is defined in 2 files

    • library.js, in line:197, inside object templateData
    • composer.js in line:457, inside object data

    when are each definition used?
    From the look it seems one is for server side and the other one is client side? Are the two object synchronized at some point then?

    Thank you.

    PitaJP 1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    replied to erichbb on last edited by
    #2

    @erichbb direct links to the code:

    https://github.com/NodeBB/nodebb-plugin-composer-default/blob/921837c20b38540c36e219a4c526b43d23ace858/library.js#L206

    https://github.com/NodeBB/nodebb-plugin-composer-default/blob/921837c20b38540c36e219a4c526b43d23ace858/static/lib/composer.js#L456

    Yes one is server side and one is client side.

    E 1 Reply Last reply
    0
  • dogsD Offline
    dogsD Offline
    dogs
    wrote on last edited by dogs
    #3

    @erichbb I think this might help you:

    howto: inject hidden data into composer?

    @yariplus Nice! I will explore other features first while waiting for the merge and release. Yes, got your point that "anything on the client is modifiable" :).

    favicon

    NodeBB Community (community.nodebb.org)

    Of course your fields don't need to be hidden. But with this example and editing composer you should be able to add fields to composer as default. Hidden as well as visible. 👍

    E 1 Reply Last reply
    0
  • E Offline
    E Offline
    erichbb
    replied to PitaJ on last edited by
    #4

    @pitaj
    when does that server side code (filterComposerBuild method) runs?

    Specifically, I know it is binded to the hook filter:composer.build method I do not know when does that hook fires.
    I have put some console.log() statements inside the filterComposerBuild method, but I can't find the output from either brower's debug console or nodebb backend terminal (running in ./node dev).
    And from the name of the method, it seems it is only executed once when the composer initializing?

    Which hook should I bind to if I want react to interaction? (Or are hooks only relevant for server side stuff?)

    link to filterComposerBuild()

    Thanks.

    1 Reply Last reply
    0
  • E Offline
    E Offline
    erichbb
    replied to dogs on last edited by erichbb
    #5

    @dogs Thanks.
    Can you point me to some materials explaining how the frontend and hooks interact?
    I don't complete follows their discussion on data.submittedData and is still confused about which variable is the post data stored in and which hooks are involved when it is passed around.

    Edit:
    Also found this, maybe relevant
    Difference between templateValues and templateData

    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