uniqueness of ID: single page or entire website? - html

Case study: I have a website with many archive pages. Every archive page contains a list of news and also a "Load more" link at the bottom of page to load more content by Ajax.
My exact question : Is the uniqueness of ID is bounded to a single page or entire website? Should I write CSS,scripts etc. with the class of "Load more" button or its ID? I know both of ID and Class work programmatically but I am asking about the logical application of ID in software programming. Thanks.

Is the uniqueness of ID is bounded to a single page or entire website?
A single page.
There is nothing wrong with having multiple pages wherein the same ID is assigned to the same element in every page that uses the same template. In fact, there is nothing wrong with taking that same ID and reassigning it to some other element instead in a specific page, or not assigning the ID within that specific page altogether.

Whilst it is true that it is unique to a given page - take care with this, since you may have a common external CSS sheet or javascript page that is inserted and utilised site wide. Therefore if you are not careful you may inadvertently apply styling or functionality to an element that is unintended - simply because it shares an id with another element on another page. Its absolutely fine to have same id's on each page (and it may be that you want to have the same styling or function applied) - but it may not be that for all instances.

Related

TYPO3 Ke_Search: How do I have multiple search forms on one page without them interfering each other?

I have a search form in my header rendered as a cObject from a content element which is a ke_search searchbox and it leads to a /search page when submitting.
I also have subpages that are supposed to only look through seperately indexed pages like news and other pages.
For that I have folders in the typo-backend which contain indexer configs.
My problem is that when I set up that search box in the header the other searches are using the indexer config from the header (probably because it's the first searchbox on that page).
How do I make sure that every searchbox uses it's correct index?
As mentioned: Everythings seems to be split up nicely in the backend.
I can only imagine that somethings going wrong because the searchboxes are rendered with the same id but how can I make sure they render with diffrent ID's?
I managed to get an answer from the team behind Ke_Search.
When implementing a global searchbox that is used across every page, you should implement the searchbox as plain html and not as a content element in Typo3. You can only have one searchform as a content element per page.
Here's the documentation on how to implement the html version:
https://docs.typo3.org/p/tpwd/ke_search/main/en-us/Templating/Searchbox.html#include-searchbox-with-plain-html
Just leaving this here for anyone running into the same issue.

Show a particular DIV from a previously viewed page

I'm not sure if this is possible (I'm not a coder!) but here goes anyway...
The DIV class for the product name on the following page is "productTitle"
https://www.ultimadisplays.co.uk/Alcohol_Hand_Sanitiser_Gel/?categoryId=2147499177&tab=0&subTab=1
I won't bore you with why but the website is very old and limited however we can put a button on each product page which can link to a form. This form is on a completely separate hosted platform.
Is it therefore possible to take the product name over to the new page with the form on it using the DIV class so that when the form is submitted we will know what product they are interested in rather than they have to write it into the form manually?
Thanks in advance!
You can send whatever data you want between different sites or platforms by sending it in GET or POST request either by refreshing page directly or by using AJAX.
I don't think it's a good option just for a form. But you have this possibility nevertheless.

Generating identical html elements on multiple asp.net forms

The title is probably misleading, but I'll try to explain it better here:
I have a div with an ID of "errorBox" that I use on 3 separate forms within the same website. They aren't in the same position, however, on each form's .aspx page, which is why I've ruled out incorporating it in the master page. Additionally, I would like to be able to call said div by identity within each form's code-behind page. Is there a way I can define this div and its contents only once on my website instead of copy-pasting it on each form's .aspx page?

Using microdata on elements created after during page load

I need to add microdata snippets to a list that is being populated by a script during the page load.
My code is written in a way that I have the basic list element in my html code, and it gets duplicated as the list is populated (this happens once when the page is loaded).
I try to add microdata to every element in the list, but when I use google's rich snippet tool it seems that it only reads the basic html snippet and not the whole list after it was populated. I do the exact same trick on a different page and there it seems to work fine (meaning i get a list of videoObjects each containing the data inserted to it) [edit: the second page was created on server side, this is why it worked on it].
Any idea how to get around problem?
As a general rule, search engines do not read content dynamically created by JavaScript. So anything your script dynamically creates will be invisible to Google. If you want them to index this content you need to create this content server side.

Orchard CMS - theming

I have some questions regarding theming Orchard CMS. So, let's begin... I have a website that will have 5 pages and some of them have different layouts.
Pages and zones within it:
Homepage - Content, TripelFirst, TripelSecond, TripelThird
Concept and Rentals page - Content, AsideFirst, AsideSecond
Press and Service Department page - Content, AsideFirst, AsideSecond (different layout then the previous two pages)
Note: Even though all of the pages have the Content zone, except Homepage none of the pages uses it. Other pages only have HTML widgets located in one of the zones.
1) I've read that it is possible to create the layout for the specific ID, the problem is I can't find that ID to create the layout for specific ID.
2) As you can see, couple of pages have the same layout, how to assign them to the specific layout? For example, if I create the layout for Concept and Rentals page how can I assign the specific layout to them and also how can I assign the layout to Press and Service Department pages?
3) How to add the class tag to the body? The problem is that Orchard CMS creates the body before everything else so it isn't contained in the layout cshtml files.
Thank you in advance!
when you edit the page in the admin, the url will look something like http://localhost:30320/OrchardLocal/Admin/Contents/Edit/16
16 is the id here.
Several things you can do. Easiest is to use this module: http://orchardproject.net/gallery/List/Modules/Orchard.Module.Downplay.Orchard.LayoutSelector
Alternatively, you could programmatically create alternates based on arbitrary criteria: http://weblogs.asp.net/bleroy/archive/2010/12/14/switching-the-layout-in-orchard-cms.aspx
Finally, you can often avoid to have to create an actual separate layout by just varying what widgets go where, using layers.
The body tag is in document.cshtml, which you can override in your own theme.
1. Not sure what you mean by ID? If you click Widgets on the DashBoard, there are Layers there. A layer is a collection of widgets that will activate for a specific thing, Like the authenticated Layer will display those widgets you define when a user is authenticated.
Expanding on (1) and for (2), you will be able to create a new layout by adding widgets to a layer.
Check out:
Tagged Layer Rule - Allows you to add widgets based on a tag. Now, you can add pages for concepts and rentals and then specify a layer for these tags, within that layer, you can add any widgets you like. These will only appear when that tag is encountered.
Also check out:
Content Type Layer Rule - Haven't tried this, but it falls on the same lines.
3. To customize the look there is something called Shapes. Each Zone I think has a corresponding cshtml files. You can even use the ShaperBuilder to even render html in code, again, don't know too much about this but I can tell you, you need to look into these articles.
Using shapes as Html helpers in Orchard
Using shapes as Html helpers in Orchard
Taking over list rendering in Orchard
Dispatching Orchard shapes to arbitrary zones
HTH, I'll try and contact some orchard folk that are on SO.
So to help you out here
The ID of the Home Page is always 11 for a fresh install though I imagine that you can delete the home page and create a new one and give it another ID. To find the ID of the other pages open up the DB and look at the Content Items.
I know of no way to apply Layouts other than by ID so just duplicate the layout pages as you have so few pages.
I would just use a small jQuery script
$(document).ready(function{
$('body').addClass('SomeClass');
});