Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7819925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:06:59+00:00 2026-06-02T07:06:59+00:00

I have manipulated the code in this application , and put in a sidebar

  • 0

I have manipulated the code in this application, and put in a sidebar in the views/layout.jade file. In the sidebar I’ve cut/pasted the code for handling tags from views/index.jade:

    ul.tags
        each tag in tags
            a(href='/tag/' + tag._id.toHexString())
                li.tag= tag.name

The tags are fetched from the db as they should, and rendered out in the sidebar, however when I click on one of them (which should show a new page with all the posts tagged with the tag) I get an error message:

500 ReferenceError: ... layout.jade:10 8| p 9| ul.tags > 10| each tag in tags 11|   
  a(href='/tag/' + tag._id.toHexString()) 12| li.tag= tag.name tags is not defined

Here’s the function that’s called in the file “tagcontroller.js” (that’s handling the logic for the tags):

app.get('/tag/:id', function(req, res){

    model.Tag.findById(req.params.id, function (err, tag){
        if (err) {
            console.log(err);
            // do something
        }

        var query = blogModel.BlogPost.find( { _id: { $in : tag.blogs } } );
        query.where('date').lte(new Date());

        query.exec(function (err, blogs) {
            if (err) {
                console.log(err);
                // do something
            }

            var query = model.Tag.find({});

            query.exec(function (err, tags) {
                if (err) {
                    console.log(err);
                    // do something
                }
                res.render('tags/detail', { title: tag.name, blogs: blogs, tagList: tags, dateFormatter: dateFormatter });  
            }); 
        });
    });
});

If I put back the code into views/index.jade, everything works fine. But I need to have it in layout.jade to be able to show it on every page, not only on Home (index.jade).

I would really appreciate some help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:07:00+00:00Added an answer on June 2, 2026 at 7:07 am

    Right now, you have:

    res.render('tags/detail', { title: tag.name, blogs: blogs, tagList: tags, dateFormatter: dateFormatter });
    

    But if you are doing a each tag in tags, then you should have something like

    { title: tag.name, blogs: blogs, tags: tags, dateFormatter: dateFormatter }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the first time I have manipulated hashes and arrays in this way
My application I have an application design that looks like this: web application layer
I have an Excel file that has a bunch of VBA and macro code
I have an Excel file with a large set of VBA code. There are
I have a (problem?) where my application's main form code is becoming quite large.
Let's say I have a buggy application like this: using System; namespace ConsoleApplication1 {
I have a situation where I have already obtained and manipulated SQL data into
I have an application which manipulates high resolution images (something around 100+ megapixels), and
I have an interactive web application powered by jQuery where users can manipulate visual
Greetings! I inherited a C#.NET application I have been extending and improving for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.