Orchard - Getting the Content's Title from the Theme Layout - asp.net

This is going to drive me crazy at this rate. From inside of a Layout.cshtml file for a theme in Orchard, how can I determine the Title of the main body's contents?
I've tried using the Shape Tracer but it doesn't seem to help. None of these give me any text at all.
#Html.Title()
#Model.Title
#Model.Content.Parts_Common_Body.ContentItem.TitlePart
#Model.ContentItem.Parts_Common_Body.ContentItem.TitlePart
UPDATE:
Here's the HTML which should show what the end result needs to look like to keep the theme intact, along with a picture showing the theme before I started with it. This HTML is just a snippet of the parts that I'm concerned with. In the picture, the search is what is in the ContentHeader zone.
<div id="wrapper-header-inner">
<div id="header-inner">
#Zone(Model.ContentHeader)
<h1 class="pagetitle">
Title Here
</h1>
</div><!-- #header-inner -->
</div><!-- #wrapper-header-inner -->
}
<div id="wrapper-content">
<div id="content">
#if(Model.Content != null) {
<div class="main" class="#mainContentClass">
#if(Model.Content != null && Model.LeftAside == null && Model.RightAside == null) {
<div id="maincontentFull" class="positionleft">
#Zone(Model.Content)
</div>
}
#* Other layout possabilities if left and/or right asides are present *#
</div>
}
</div>
</div>

As a follow up, updates to Orchard since I have asked this question included the ability to use the placement.info file to reroute certain parts to other zones, in effect letting me accomplish what I was looking for.
<Placement>
<Match ContentType="Page">
<Place Parts_Title="/TitleZone"/>
</Match>
</Placement>

From Layout, Model is the Layout object. It has nothing to do whatsoever with whatever content is going to get rendered into the Content zone, but it does have a Title property that should be set by that content. It is not exactly what you are asking for though: it is what will end-up being the HTML title.
If you want to get to the title of the item that gets rendered into the top-level Content zone, well, Layout is really not a good place to look for that. I would need to know more about what exactly you are trying to achieve but this seems backwards. In fact, you can't even assume that there is one such content item, or that there will be only one.
So what is it exactly that you are trying to do?

Does this work for you?
#Html.Title()
That should work if you're looking for the page title. However, if you're looking to directly access the TitlePart...
#Model.Title
This works because if you look in the Parts.Title template there is a line of code that does this...
#{
Layout.Title = Model.Title;
}

Related

How do I wrap a label in a div within a class to modify it?

I'm looking for the method to put a label and text in a div, within a class.
I have this html:
<div class="awpcp-subtitle">Contact Information</div>
<a href="https://adsler.co.uk/wp-user-test-dashboard-
2/awpcp-reply-to-ad/13/madame-bovary/">Contact
Anonymous</a>
<br/><label>Phone:</label> 7576XXXXXX
<br/><label>Location:</label> London, UK
</div>
<div class="showawpcpadpage"><label>Price:</label>
<strong>£ 3.00</strong></div>
<div class="fixfloat"></div>
I want to put the label 'phone' within a div class and, if necessary, the text after it in a div class.
Basically the aim of this is to be able to select the label 'phone' and the text after it, and give it a background color.
I don't know where I would insert it in given html, or even what it would lool like?
Im guessing somewhere after 'Anonymous,'
so:
Anonymous</a> div class="Phone:"><label>Phone:>.
</label>
and then continuing with existing code:
<br/>label><Phone:></label>7576XXXXXX
<br/>..........
First of all, I would suggest you go through some basics of HTML. This would be a good start: https://www.w3schools.com/html/
Now coming back to your question, you could enclose it like this:
<div class="awpcp-subtitle">Contact Information</div>
<a href="https://adsler.co.uk/wp-user-test-dashboard-
2/awpcp-reply-to-ad/13/madame-bovary/">Contact
Anonymous</a>
<div class="phone"><label>Phone:</label> 7576XXXXXX</div>
<div class="location"><label>Location:</label> London, UK</div>
</div>
<div class="showawpcpadpage"><label>Price:</label>
<strong>£ 3.00</strong></div>
<div class="fixfloat"></div>
Here, I have removed the <br> because you were using it to make that Phone and Location display in separate lines. Since we are using <div> tags are block level element by default, the contents of it will be displayed in separate lines.
So, now you can change the color of those two boxes like this:
.phone{
background-color: red;
}
.location{
background-color: yellow;
}
And lastly you asked about how to do this in Wordpress. As you may already know Wordpress uses Themes, you have to check which one is your current theme (the one that is running in your website). This can be checked via visiting Wordpress Admin Panel --> Appearance --> Themes. You will see the current active theme's name in that page. Now you have to use an FTP Client or the File Manager in your cPanel to access the following the location: /wp-content/themes/yourthemename/ in your server. Here, youthemename is the name of the theme that you noticed in the previous step.
Once you are in that folder, you would see a bunch on template files. I would suggest taking a close look at each file if you are unsure. Or its better you get a basic idea of Wordpress first before editing it. Take a look at this: https://developer.wordpress.org/themes/basics/template-hierarchy/
Once you find out the template file has this HTML code you wanted to edit, simply open it and make the changes and save it. You are all done. If you are using any Cache plugins in your Wordpress, you might need to purge the cache if you don't see the changes when accessing the webpage.
That being said, my writeup might give you a small confusion. That's why I suggested to have a look at the basics first. Otherwise you have to hire someone who would be ready to do that specific changes for you.
Hope it helps.

how to create a css class that makes an element link to another page

super css noob here.
I'm using a wordpress plugin called visual composer which allows you to name a Row (it's like a block element) with a Row ID or a Class name. I'm trying to have it so when a user hovers over this row and when they click it, this clicking will simply take them to another page within my website.
It allows for an area to have the css for this class or ID that I can associate with the tag, but after searching I'm either searching the wrong thing or can't find it but I am looking for the css that would allow me to do this!
You can't only use css to link to other page, you need javascript. For example the class name is linkPage:
document.getElementsByClassName('linkPage')[0].onclick = function(){
location.href= 'some url...'
}
<div class="linkPage">linkPage</div>
You'd need to inject a bit of JS into the theme that listens on window for a click with the desired ID or class, then call window.location.href = URL or something of that nature.
CSS doesn't have the power to cause browser location changes.
CSS
CSS (Cascading Style Sheet), as its name states, defines a set of rules and properties for an HTML page you wish to style (stuff like colors, size, asf); and user interaction (even as minor as pointing to an URL) are not part of its scope.
Basic
Talking about a giant like WordPress and a strong plugin such as Visual Composer, extremely old and standard features like link/image/table asf are always to be found. You may have a look at visual composer's "Raw HTML" feature (https://vc.wpbakery.com/features/content-elements/) in combination with a regular "a" tag (http://www.w3schools.com/tags/tag_a.asp).
Editable
Asking how page linking can be achieved through editing of a CSS file, then you might as well look into different editable content types of the plugin - such as HTML or JS.
Click on table row
Best approach to have table cells/rows clickable would be by the use of JavaScript; see Adding an onclick event to a table row
Link using jQuery and Javascript (easier method):
$(".link").click(function(){
window.location.replace('https://www.example.com');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="link">link</div>
<div class="link">link</div>
<div class="link">link</div>
<div class="link">link</div>
<div class="link">link</div>
Link using pure Javascript (harder method):
x = document.querySelectorAll('.link').length;
y = 1;
while (x => y) {
document.getElementsByClassName("link")[y].onclick = function() {
window.location.replace("https://www.example.com");
};
y++;
}
<div class="link">link</div>
<div class="link">link</div>
<div class="link">link</div>
<div class="link">link</div>
<div class="link">link</div>

get image TV on homepage modx revolution

I have a lot of sub pages and latest 3 I am showing at homepage, I could display only title but image can't(every sub page has TV named 'image_prew' and I am trying to get value of this TV for image), here is my code:
<div class="cat">
<div class="role">
<h1 class="[[+pagetitle]]">[[+pagetitle]]</h1>
</div>
<div class="menu_prew-[[+pagetitle]]">
<img src="[[*image_prew]]" class="image"/>
</div>
<div class="clear"></div>
</div>
You don't say how you're fetching the sub-pages, but if you're using getResources you need to use the parameter &includeTVs=1.
And as Sean mentions above, in a template chunk TVs are placed in a placeholder tag -- use a plus sign not an asterisk.
try [[+tv.image_prew]] and check the documentation near the bottom "Displaying Template Variables with getResources" is clearly labelled
What is your output setting on the TV? Whenever you are outputting image source urls in your TVs, make sure in your output setting tab the output is set to "text". You want the text to render to your html tag. Default may or may not work depending on your input type setting, so I always force this to "text". I have had that issue once or twice;).

Wordpress div class container, is it special in wordpress?

Hiall,
could someone please tell me, is the
<div class="container">
class/element some kind of special class for wordpress???
This div is currently wrapping all the content on my site and I am trying to put html code outside of this div, but no matter what I do it won’t let me and it automatically puts everything inside this div.
I’m looking at the file that contains the ending
</body>
</html>
tags for the document and when I try to put code right before the end like
<div class=“myotherrclass”></div>
</body>
</html>
When I load the page in the browser the last tag before , it automatically always puts the closing tag for the container div! eg.
<div class=“myotherrclass”></div>
</div> <!— container class closing div, automatically appears from no where! —>
</body>
</html>
Any help trying to understand what is happening would be great
I started with the Underscores.me starter theme and just deleted the "container" div from both header.php (the opening) and footer.php (the closing). And...nothing bad happened! Will report back if something does, but right now I'm deleting div tags not being used in order to make sense of what's going on. This one's gone!

Incorrect Position on <div> Element

I'm trying to make a simple yet interactive webpage for my school. Our current homepage we use for links is plain and boring.
I've created this: JSFiddle
But when I open the 'Student Links', the 'PHHS Website' button seems to automatically position itself ~50 pixels up.
Code because I have to:
<a class="itemLink" href="http://hcps.us/phhs/">
<div class="itemStudentsLink" id="PHHSWebsite">
<p class="itemText">PHHS Website</p>
</div>
</a>
If anyone knows why it's acting like this, please tell me. I'm not sure why this problem occurs.
This has to do with the vertical alignment of the blocks and the fact that one of the block's text goes onto two lines. Add
.itemStudentsLink {
vertical-align: bottom;
}
http://jsfiddle.net/ExplosionPIlls/mKYaL/19/

Resources