Editing .tpl files

Technical Support

Suggested Topics


  • Serving Dynamic .js Files on Node?

    Unsolved Technical Support
    0 Votes
    4 Posts
    90 Views

    It looks like Express is the way to handle static resources in NodeJS. It looks like they are being set up in <index.js>. I have no idea why the javascript resource is inaccessible.

  • 0 Votes
    1 Posts
    197 Views

    Hi all,

    I'm trying to use the recently introduced WriteAPI to create topics and concurrently upload a file.
    I'm doing it via Python and I've already succeeded in create a simple topic without a file using something lilke

    payload = { "cid": cid, "title": title, "content": message } headers = { 'Authorization': 'Bearer '+nodebbToken, 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=json.dumps(payload))

    but when it's about files using

    payload = { "cid": backstage_cid, "title": backstage_title, "content": backstage_message } headers = { 'Authorization': 'Bearer '+nodebbToken, 'Content-Type': 'multipart/form-data' } verifySSL = False print (payload) if (useFile): with open(backstage_file, 'rb') as f: response = requests.request("POST", url, headers=headers, data=payload, verify=verifySSL, files={backstage_file: f})

    it returns
    Error: Required parameters were missing from this API call: cid, title, content cause passing the parameters in a plain dictionary rather than a JSON object seems not doable.

    The switch from JSON to dictionary is needed otherwise I wouldn't have been able to pass a file together with such header

    headers = { 'Authorization': 'Bearer '+nodebbToken, 'Content-Type': 'multipart/form-data' }

    Has anybody valuable suggestions here?

    Thanks in advance, Riccardo

  • 0 Votes
    12 Posts
    805 Views

    @baris
    ok and I can use the conf file to use like a +2 string and make a PR ?

  • Edit/remove tags

    Technical Support
    0 Votes
    4 Posts
    2k Views

    That's correct.

  • Accessing data inside header.tpl?

    Moved Unsolved Technical Support
    0 Votes
    13 Posts
    3k Views

    Here is what I have done, I finally figured out how to get a list of categories, I kind of like this method but I hate having to pass an array, but it is what it is.

    var theme = {}; var catLength = [1,2,3,4,5,6,7]; var Categories = module.parent.require("./Categories"); theme.init = function(params, callback) { Categories.getCategoriesData(catLength, function(err, data) { data.forEach(function(something, index) { if(something) { console.log(data[index].name); } }); }); callback(); }; module.exports = theme;

    Cool now I have all the categories and the next step is to create a dynamic header based on the categories, the problem is I am so confused on how to do that, I think I am missing something very obvious!

    I am inside a theme and I want to pass this into the precompiled template! 🙂