i have 2 different layouts in express js , I store all navigation maues in database tables now i have to load menus according to layout e.g home , about, contact for front end layout and dashboard,manage ,ticket for admin Panel in my website.
i stuck on which event or route i have to use for load it.
Related
I have a svelte application, I have separated the backend from the frontend by making two different directories the backend is the express application and the frontend is the svelte app. I fetch the data from the express server when it is needed. I need an admin dashboard where I can control things but the problem I am getting is that I don't want to display the static HTML and the svelte files that are supposed to be on the admin page.
Now if I go to the browsers dev tools I can see the components that are displayed on the admin page and the code inside those components. Of course, the user can't access the sensitive data that is stored on the express server, but still, I would like to keep the admin page completely hidden.
I can fix this by making a get route on the server side and running a middleware in between that checks that the user is admin and then just renders the HTML, but the admin page needs to have a lot of functionality so I need to use svelte.
Image from the browsers dev tools
I found an answer! I was using the <a> html tag to navigate to the admin page and the data was preloaded for some reason. In my launched app I don't need to navigate to the admin page using the <a> tag.
How to reload the page without reload partials in node js. I am creating a web application using node js, bootstrap, mongodb and handlebars. In my partial navbar the active class and js code for changing it into clicked component. when I render a page inside this the whole document is reloading and active class changing is uneffective in this case. I think it will be fixed with avoid reloading partials. There is any way to avoid reloading partials when page rendered.
I'm working on assumptions here as you haven't posted any code, I assume that:
You are using Handlebars to render the partials on your Server? (not on the client)
You have setup separate routes on NodeJS (are you using express?) so each route serves a different page, e.g. "/Index", "/About", "/Privacy", "/Contact" etc.
If my assumptions are true, each route on your server is providing an entire web page. It must re-load the partial because the client expects a complete html page for that route, and whenever the client changes route the server must provide a new page; if it didn't reload the partial then your navbar would be missing.
If you want a more seamless experience where the navbar stays there and you can modify its state, and only the remainder of the page reloads, you ought to try the Single Page Application approach. Frameworks such as Angular, React, VueJS or Svelte are designed with this approach in mind. Your routing and page templating is done client-side rather than server-side, but you can use a combination of both (I use Handlebars and VueJS)
I am developing a website from where people can download files. I will upload files to the website which will show up at the home page. Now I want to make only the first 10 files to show on the home page . Rest of the files will be shown in the next page. I mean Only ten files will appear on a single page. Then you have to click 'next' button to view more files. I am developing the website with nodejs express js . Can you tell me how do I do that?
This feature is known as pagination, you need to handle on both front and backend. it is a detail process so i will share some links for reference
Backend Pagination with node express mongodb mongoose and EJS
Simple Pagination with Node.js, Express, and Mongoose
Server Side Pagination Using Node and Mongo
I want to Create a Materialized Frontend WebPage with a Navbar having static Searchbar placed inside it in the center. Just like in ecommerce websites like flipkart and snapdeal etc. what is the best way to do it using materialize.css???
Im building a single page app with NodeJS/ExpressJS & Backbone/Marionette.
My App consists of routes like mysite.com/user/:UserID in which :UserID matches up with any of the thousands of users in my database. So if someone types mysite.com/user/1234, the profile of user '1234' appears.
But now i'm confused in how to get each dynamically loaded profile to appear in a static google search?
For example how sites like Facebook or Twitter have a User Profile appear and indexed when I search it on Google, even though it has the appearance of a single page app.
I've been researching the following solutions, but not sure which will lead me to what im trying to accomplish:
1) PhantomJS snapshots
2) Make Isomorphic App(using Facebook's react.js or Airbnb Rendr)
3) Change URL's to hashbang #! format (appears to be outdated in favor of backbone pushstate)
4) Use Prerender: https://github.com/prerender/prerender-node
Also read up on SEO and dynamically loaded content appearing on Search Results, but im not sure if its the same thing.
I've Done the following:
1) Using Backbone PushState in that url address bar changes to the new profile clicked without reloading the page.
2) Set up express routes so when user types in address bar , then 'Enter', mysite.com/user/1234, it loads profile '1234'