I have pretty simple landing site (index, faq, about, contact) based on ASP.net MVC. Of course, I use Layout (with head and footer), every View contains just page content. The problem: some pages has unique footer or head.
For example:
Index page has carousel (only this page, other pages has no carousel).
In source HTML (that web-designer sent me) I see scripts links in the head and scripts block in the end. Yes, I know: I can use Razor tag "#section" and declare this non-standard head and footer inside my view.
But! It means my view (page content) includes razor syntax. This is not pure HTML. What if site admin will want to edit index page - he will see Razor tags, he can't use some html editor or online tool (TinyMCE) for edit. He must know Razor. He can't just insert pure html.
Maybe I shouldn't keep page contents in DB? (but this site must support multi-lang). What is the best approac in this case?
Thanks.
Related
I am new to HTML/CSS and in this project intend to create a simple web page in such a way that each page links to three other HTML pages.
<div id="mySidenav" class="sidenav">
Home Page
about
Projects
Contact
</div>
My questions:
Is it possible to link to other pages other than the page itself via
programming (to write if page_name == link.html then exclude it from
the links)? e.g., I want to tell my HTML that if I am in the "about"
page, don't add the link to this page.
If that is possible, how I can fill the self-link button without using JS.
Yes, it possible. First, you have to know about PHP. Then get the current page url by $_SERVER['REQUEST_URI'].
IF the current page url is matched with your link like about.html then ignore the link for the same current page.
Otherwise, you can create a separate page with ignoring link. Like when you at about page ignore that link.
The short answer is no. HTML isn't a programming language and has no flow control or logic capabilities. You could achieve this via server-side rendering (express or php or whatever) or via static site generation (gatsby, etc.).
Otherwise you could (of course) modify the nav on each page accordingly, but I understand and agree that that's less than ideal.
This is a bit of a stretch, but you could link to homePage.html#homePage and use the CSS :target pseudo-selector to hide the current item or give it special css treatment, but this is sort of a brittle hack and it will break down if the fragment (#homePage, #projects, etc.) isn't present in the browser's url.
In ASP.NET Webforms I have a Master Page where bootstrap css is imported. All of the child pages of the site use this Master Page.
One of the child pages displays HTML content originally created in a WYSIWYG editor. Since this child pages uses the master page and relies on it so the header and footer match everything else the styles override the WYSIWYG content styles.
Is there a way I can make it so a section of the page ignores bootstrap even though it is being imported from the master page but the rest of the page like the header and footer still use it?
Trying to avoid separating this page from using the Master Page.
The only possible method I can think of would be to create a custom css file for this page, and create specific css classes for each element that will override the css imported from the bootstrap via masterpage.
I'm building a simple personal static webpage. It'll be 4-5 pages (maybe more later) that all share a nav bar and header design at the top of the page.
I don't want to repeat the HTML and CSS for the navbar/header at the top of every page - ideally I'd like it all in one place.
If I were creating this using a web framework like Django, Sinatra, Rails, etc... I could use templates and partials to build the page using shared components like the navbar/header.
But I'm trying to keep things as simple as possible since it's a small set of static pages.
Is there a way to keep all the HTML in one file and reference it from the other files?
If not, is there a simple tool that will let me leverage the functionality that partials and templates provide, and just "compile" the final product into a series of HTML pages?
Thanks!
Use a one main Html file with all navigation bars, footer, menu and etc.
Keep a blank place, for example a blank div in the main page.
Keep other html pages in a separate place.
Load the contents dynamically to the blank div in the main page using javascripts.
I'm new in liferay, into my portlet i have html pages with angularJs not jsp.I would ask about how to navigate between these html pages into my portlet..thanks.
I think you are bit confusing about technology.
JSP pages always generate HTML page for your browser.
It means that you create a JSP page containing just HTML nothing changes (this is correct from a developer point of view... thinking to server job this is not true... but think it is true for our purpose).
Client side technology you are going to use is not relevant from a portlet point of view (it can be a problem if your theme uses some not compatible libraries...) but in general whatever library you use (angularjs, backbone etc.).
It means that you can create html or jsp pages containing all the angularjs code you want... and everithing should work fine.
If you want to manage navigation between "pages" in the same portler (e.g. from view.html to details.html) then you have to mind, simplifying, that portlets haven't pages: your portlet will be added in a page of the portal (with its own URL).
So you can rename your html files in jsp files (as I told, nothing changes), then you can tell to portal what is the correct URL to load by JSP code.
For example for making a link to "details.jsp" in your "view.jsp" you can write a code like following:
<a href="<portlet:renderURL>
<portlet:param name="jspPage" value="/path/to/your/details.jsp" />
</portlet:renderURL>">Text</a>
Obviously you can use the <portlet:renderURL>...</portlet:renderURL> code wherever you want... because it will be translated in a string before sending to browser... like in javascript var url = "<portlet:renderURL>....</portlet:renderURL>"
You shouldn't forget to put these lines at the beginning of yout jsp files:
<%# taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<portlet:defineObjects />
I created a mvc4 web app. with razor view engine. There are Layout page and content pages(Home, Contact, About, etc.) you know. But there is no reference to layout from content pages.
Should do not content pages include this:
Layout = "~/Views/Shared/_Layout.cshtml";
In content pages this code is missing.And they works.
How does it do this without layout reference?
It's because partial views are included into a 'non-partial' page, which does have a layout defined.. So they make use of that and just become a part of that page
EDIT
I'm sorry for the late reply, I just checked it out and it appears to be cause of the _ViewStart.cshtml page, this is a page that runs before any view is rendered, read more here:
weblogs.asp.net/gunnarpeipman/archive/2010/10/10/…
thats your masterpage if you want a partial view
#Html.Partial("partialviewname". "controller")
and the partial view doesnt use the masterpage since it is inserted to a place you desire