Orchard does not shows Model properties in custom views - content-management-system

after couple of hours of trying I am absolutely clueless about how customize the way Orchard displays blog posts in lists and individual view.
IEnumerable<object> blogPosts =
Model.ContentItems.ContentItems;
<ul class="content-items">
#foreach (dynamic post in blogPosts) {
string title = post.Title;
ContentItem item = post.ContentItem;
<li class="content-item-summary">
#Html.ItemDisplayLink(title, item)
</li>
}
</ul>
This is my code for displaying blog posts in list. I am only able to show title surrounded with hyperlink. I cannot figure out, how can I access Body text, Tags or even image added as field. #Model.Body.Text and various other does not work.
I must be doing something very wrong, because it cannot be that hard, can it? I previously created some sites on Umbraco and was able to accomplish this very easily.
I want my list to contain for every post title (done), then excerpt from body and image from Media Library Picker Field. It shows everything automatically when I open individual articles.
I watched Pluralsigh fundamentals, read documentation, experimented with shape tracking...
Thanks for any help or pointing in the right direction.

You can access the other parts like so:
ContentItem item = post.ContentItem;
var bodyText = item.As<BodyPart>().Text;

Related

Need to distinguish like icon from unliked icon

I need to click like icon but after checking the condition, if this is already liked or not. So i need two different locator paths to differentiate between the two. The only thing different is the classes but the class name has spcae in between and the protractor cannot locate the space class name, even after adding dots for space.
My protractor code and html structure is in the picture:
It's not clear what you're trying to achieve. If you update your post showing html of liked icon and not liked icon and what your script is doing i can give you a solution.
If your element is <i class="fa fa-heart liked">.
There are three ways to locate such elements using CSS.
$heart = $('i[class="fa fa-heart liked"]');
$heart = $('.fa.fa-heart.liked"]');
$heart = $('i[class*="fa-heart"][class*="liked"]'); // contains partially
Also you have an option using xpath

News 3.0.x - how to keep overwriteDemand

I have setup the TYPO3 news extension (not tt_news) to show a date menu with archived news items. From the archive menu, you can go to the list-view with all news for a given month. From the list-view, you can go to the details-view, to actually view the news item. In the detail view, I have configured the list-view as PageId to return to.
I think this is a standard setup and has nothing special.
The link from the date-menu to the list-view contains the GET parameter "overwriteDemand", which adds the month and year to the demand of the list view, so only the news articles for the given month/year are shown. Actually this GET parameter is not kept, when linking to the detail-view (with the n:link viewHelper) and therefore also not given back to the list-view, when I go back to the list-view from the detail view. The list-view therefore shows all news records after I come back to the list view from a detail-view.
Adding a javascript.back() button is no solution for me, since I want to use real links.
Am I missing something or is this a missing feature?
There are two ways to handle this.
the first option is, to edit the templates and add the parameters to the links using the arguments parameter of f:link.page (or something similar).
Second option is, create a new extension-template in the tree of the single page and add some typoscript, which keeps the parameters in the rendered link. The config name ist called linkVars and is descriped here: http://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#linkvars
tx_news uses <f:link.page in his templates. I just checked on github tx_news to see if it changed, but it still looks the same.
This is how tx_news generates the backlink:
<f:if condition="{settings.backPid}">
<!-- Link Back -->
<div class="news-backlink-wrap">
<f:link.page pageUid="{settings.backPid}">
<f:translate key="back-link" />
</f:link.page>
</div>
</f:if>
So it looks like the overwriteDemands are not kept. I think it would be a really good sugestion to the tx_news Dev-Team to keep the overwriteDemands in the backlink.
You have the {overwriteDemand} as an object in your template, so for now you can use something like this:
<f:link.action pageUid="{settings.backPid}" arguments="{overwriteDemand:{year: year, month: month}}">
First, you have to write a bit of typoscript to store the pagination currentPage :
lib.currentPage = TEXT
lib.currentPage {
value = 1
override.data = GP:tx_news_pi1|currentPage
}
In the paginated news list page, give the currentPage value to all links pointing to detail page :
<n:link newsItem="{newsItem}" settings="{settings}" configuration="{additionalParams:'&tx_news_pi1[currentPage]={f:cObject(typoscriptObjectPath: \'lib.currentPage\')}'}">
Read more
</n:link>
Then in the detail page, finishing by building back link to previous paginated list page :
<f:variable name="currentPage"><f:cObject typoscriptObjectPath="lib.currentPage"/></f:variable>
<f:link.page class="btn btn-xs" pageUid="{settings.backPid}" additionalParams="{'tx_news_pi1[currentPage]': currentPage}">
Back
</f:link.page>
;-)

inserting content of one template inside another umbraco

Im new to umbraco. im trying to display certain section of one template inside another template.
for e.g.
1) i have Product page, which lists all the products and few description about them.
2) now i want to show this content to my home page also. i dont want to copy and paste code from product page to home page..as this would require me to do the same if some changes come on product page.
Also, Product page contains child nodes, which automatically displayed by Macro.
i just want to display Product page contents to my home page.
Thanks in advance.
You simply need to add a new macro that will display the product page contents you need and then add it into the homepage template.
Doing it as a razor scripting file would be something like (where 1111 is your product page node id). If you use ucomponents you could use uQuery.getNodeByUrl or some other nicer helper method, but this code should work out of the box:
var productPage = #Model.NodeById(1111);
<div>
<a href="#productPage.Url">
<h4>
#productPage.copyHeadline
</h4>
</a>
#if (!string.IsNullOrEmpty (#productPage.copyBlurb.ToString ()))
{
#Html.Raw(#productPage.copyBlurb.ToString().Substring(0, 200) + "...");
}
</div>

Add Tooltips to helper html.dropdownlist in asp.net mvc

I have a dropdownlist that displays just products codes 101,102,103
If the user hovers over a product code I would like the title to appear as a tooltip.
So it's not your normal DataValue & DataText scenerio, because "101" would be both the display text & the value.
I believe I will need to use jQuery to achive this effect.
And I also believe I would need to set the Title attribute of each list item as the Product Title.
My question is, using helper html.dropdownlist how can I set the title attribute?
Thanks, this is my first day using MVC
We used tipsy once for something very similar. http://plugins.jquery.com/project/tipsy
We actually took it a step further and "created" an attribute like this
<span class="tipsyItem" tipsy="This is my tooltip text!">This is my regular text!</span>
The reason was that tipsy would still show the regular tooltip on occasion. We used some of the advanced settings like this.
$('.tipsyItem').tipsy({title: 'tipsy'});
Plus you can theme it. Also were even able to get it to support html embedded in the tooltips for links and such.
$('.tipsyItem').tipsy({html: true });
Twitter used to use tipsy. I'm not sure if they still do.

FBJS/FBML: Display a textbox on click of radio button

I want to use FBML as a canvas and would like to display a textbox on click of radio button.
Can anybody out there help me out on this? e.g. if a user selects other as option it should make appear a text box. Is it possible? how? I'm eager to learn more from the responder.
yes it is possible .
Step 1 : make a div and put text box code into that div , and assign any id to the div let say id ="textbox". and in style attribute to the div put display='none' and call below function on onclick of the radio input
function showBoxt(id)
{
obj=document.getElementById(id);
if(obj.getStyle('display')=='none')
{
obj.setStyle({display:'block'});
}
else
{
obj.setStyle({display:'none'});
}
}
i was just looking for the answer for this question as well.
and i found a useful link here.
thought i might share it.
i've tried and tested, the animation just makes it look slicker :)
function showdiv(id){
var elm = document.getElementById(id);
if(elm.getStyle('display') == 'block'){
Animation(elm).to('height', '0px').to('opacity', 0).hide().ease(Animation.ease.end).go();
return false;
}else{
Animation(elm).to('height', 'auto').to('opacity', 1).show().ease(Animation.ease.end).go();
return false;
}
}
<div id="about" style="display: none">
Facebook is a social utility that connects people with friends and others who work, study and live around them.
People use Facebook to keep up with friends, upload an unlimited number of photos, share links and videos, and
learn more about the people they meet.
</div>
Show Content.