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>
Related
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>
;-)
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;
I'm trying to set/add a class name to a div by targeting its ID but I'm not having much success at the minute.
I basically have my website navigation saved to an external file so all I need to do is make changes to one file to update all pages, but doing this restricts my website users from being able to easily identify which page of the site they are on.
I have a class="current" option that visually tells the user where they are in the menu but I can't for the life of me add the class to the navigation menu. I'm trying to run the code after the nav menu file is loaded in using the following code, where am I going wrong?
<?php include_once ("includes/page_top.php"); ?>
<script type="text/javascript">
document.getElementById('home').className("current");
</script>
className isn't a function.
Instead of this:
document.getElementById('home').className("current");
You want this:
document.getElementById('home').className = "current";
I am making a social website that each user can view his own or other user's profile. I created a user controller to handle the identity and blog, status, profile controller to retrieve information. My question is how can I make the three sub controllers ( blog, status, profile) under the user controller, like a tab view?
If you want to have Tabs in your application you should pick first an ajax framework to create andload content into them:
Assuming you are willing to use jquery:
Tabs supports loading tab content via Ajax in an unobtrusive manner.
The HTML you need is slightly different from the one that is used for static tabs: A list of links pointing to existing resources (from where the content gets loaded) and no additional containers at all (unobtrusive!). The containers' markup is going to be created on the fly:
<div id="example">
<ul>
<li><span>USER</span></li>
<li><span>his blogs</span></li>
<li><span>Whatever</span></li>
</ul>
</div>
For more info: http://jqueryui.com/demos/tabs/#Events
And the tab content will be loaded through those "controllers" which are in fact generating view scripts.
To disable the layout on your views which should be integrated inside the Tabs-panels, if the mode is simple, you can add in ZF1
$this->_helper->layout()->disableLayout();
In my ASP.Net MVC View, I have a menu. The menu consists of a number of Parent Items, with Child Items (anchor tags) underneath.
I'm using JQuery to toggle the menu items opened and closed, as the user clicks on them.
Unfortunately, once the user clicks onto an anchor tag, and gets sent to another page, the menu state is lost, and the menus go back to being closed.
Now if this was "normal" ASP.Net I'd be sticking the menu state information into the ViewState, and storing the information that way.
Is it possible to do something similar in MVC?? This is the first MVC project that I've worked on, so go gentle with me!
So let me first make sure I understand you correctly.
The user will click on a menuitem, which will take him to another page. And when he gets to that page you want the menu to reflect the fact that he is on that page? Correct?
This doesn't sound too tricky. I assume the menu is a partial view - so you would render it something like this:
<div id="menu">
<% Html.RenderPartial("Menu"); %>
</div>
So the view will already know which menu item triggered it. For example, if the user clicks on Widgets->New, you might return the NewWidget.aspx view, and it will know that the Menu item to highlight is Widgets->New. So you simply use the overload for RenderPartial to specify the name or id of the menu item to highlight.
<div id="menu">
<% Html.RenderPartial("Menu", "newWidgetLink"); %>
</div>
If it is NOT the case that a view already knows which Menu Item to highlight, you will need to pass the id of the menu item with the link. So your link generation will look something like this:
Html.ActionLink("Menu Item Text",
"Controller name goes here",
"Action name goes here",
new { menuItem = "menuItemId goes here" },
null
)
Then your action will need to handle this parameter. Easiest would be to take the parameter and add it to the ViewData. The Menu will then check in the ViewData for the Id of the MenuItem to highlight.
Maybe this: ASP.NET MVC - Is there a way to simulate a ViewState?
http://blog.maartenballiauw.be/post/2009/10/08/Leveraging-ASPNET-MVC-2-futures-ViewState.aspx
http://forums.asp.net/t/1285163.aspx
and this might help too
http://webcache.googleusercontent.com/search?q=cache:y26JBxHjbBUJ:www.beansoftware.com/ASP.NET-Tutorials/Intro-ASP.NET-MVC.aspx+how+does+mvc+save+view+state&cd=8&hl=en&ct=clnk&gl=us
There are a lot of articles about view states in MVC and since you're new to this perhaps some pre-reading would be handy and may even answer your upcoming questions!
Good luck!