Umbraco,宏,将内容从doc渲染到网站模板部分

时间:2012-08-19 01:17:14

标签: razor macros umbraco

完整的新问题 - 我到处寻找(因为我不是一个.NET发现很困难)创建一个宏,将内容项创建的信息拉入列表。

以下是我想提供的信息:

<style>
ul#showcase {
  position: absolute;
  left: 0px;
  list-style: none;
  margin: 0px;
  padding: 0px;
  text-align: right;
}

.showbox {
  border: 2px solid #ffd83d;
  border-color: #ffd83d;
  border-radius: 2px;
  background-color: #660000;
  padding: 1em 2em;
  width: 190px;
  height: 152px;
  margin-left: -110px;
  box-shadow: 4px 4px 4px -1.5px rgba(62,99,125,.8);
}
.showbox a{
  color: #ffd83d;
  text-align: right;
}
.showbox:hover {
  -moz-transition: margin-left,background-color;
  -moz-transition-duration: 3s;
  -webkit-transition: margin-left,background-color;
  -webkit-transition-duration: 3s;
  -o-transition: margin-left,background-color;
  -o-transition-duration: 3s;
  transition: margin-left,background-color;
  transition-duration:3s;
  margin-left: 0px;
  background-color:#ffd83d;
}

.showbox:hover a  {
  position: relative;
  -moz-transition: color;
  -moz-transition-duration: 3s;
  -webkit-transition: color;
  -webkit-transition-duration: 3s;
  transition: color;
  transition-duration:3s;
  color: #333333;
}

.showbox a:hover  {
  -moz-transition: color;
  -moz-transition-duration: 1s;
  -webkit-transition: color;
  -webkit-transition-duration: 1s;
  -o-transition: color;
  -o-transition-duration: 1s;
  transition: color;
  transition-duration:1s;
  color: #660000;
}

.showbox-inner {
  position: relative;
  border: 0px solid red;
  border-radius: 4px;
  background-color: #333333;
  width: 110px;
  height: 120px;
  padding: 0px 90px 0px 10px;
  margin: 0px 0px 0px 0px;
}
.showbox-inner:hover {
  -moz-transition: margin-left,background-color;
  -moz-transition-duration: 3s;
  -webkit-transition: margin-left,background-color;
  -webkit-transition-duration: 3s;
  -o-transition-: margin-left,background-color;
  -o-transition--duration: 3s;
  transition: margin-left,background-color;
  transition-duration:3s;
  margin-left: 0px;
  background-color:#333333;
}

.showbox-inner p  {
  float: left;
  width: 75px;
  margin-left: 5px;
  padding: 5px 10px 5px 0px;
  margin: 0px 15px 5px 0px;
  text-align: left;
  color: white;
    }
  .showbox-image img{
  position: absolute;
  margin: 5px -10px;
  padding: 0px -10px;
   }

.showbox-inner:hover p {
  -moz-transition:color;
  -moz-transition-duration: 3s;
  -webkit-transition: color;
  -webkit-transition-duration: 3s;
  -o-transition-: color;
  -o-transition--duration: 3s;
  transition: color;
  transition-duration:3s;
  margin-left: 0px;
  color:#ffd83d;
}



</style>

<div>
  <ul id="showcase">
</li>
    <li>
      <div class="showbox"><a href="http://www.moomookwan.org"      target="blank">MooMooKwan</a>
      <div class="showbox-inner">
  <p>Korean MooMooKwan Hapkido Association Australia</p>
      <div class="showbox-image"><img src="../media/11698/MMK.png" width=110px height=110 /></div>
      </div>
      <a href="http://www.moomookwan.org" target="blank">Click to Visit</a>
            </div></li>
    <li>
      <div class="showbox"><a href="http://www.hapkido.co" target="blank">H.I.A</a>
      <div class="showbox-inner">
  <p>Hapkido International Association Australia</p>
      <div class="showbox-image"><img src="../media/11692/HIA-Logo.png" width=110px height=110 /></img></div>
      </div>
      <a href="http://www.hapkido.co" target="blank">Click to Visit</a>
            </div></li>
<li>
      <div class="showbox"><a href="http://www.martialartsgoldcoast.net" target="blank">Warrior Hapkido</a>
      <div class="showbox-inner">
      <p>Warrior Hapkido GoldCoast, QLD</p>
      <div class="showbox-image"><img src="../media/11710/warriorhapkido.png" width=110px height=110 /></div>
      </div>
      <a href="http://www.martialartsgoldcoast.net" target="blank">Click to Visit</a>
            </div></li>
<li>
      <div class="showbox"><a href="http://www.steveshapkido.com.au" target="blank">Steve's Hapkido</a>
      <div class="showbox-inner">
      <p>Steve's Hapkido Brisbane, QLD</p>
      <div class="showbox-image"><img src="../media/11704/SHA-Bris.png" width=110px height=110 /></div>
      </div>
       <a href="http://www.steveshapkido.com.au" target="blank">Click to Visit</a>
        </div></li>
  </ul> 
</div>

我已经包含了样式(即使这将是一个单独的样式表)我的问题是,每次我创建一个变量来显示我想要的项目时,我似乎只是弄乱了它。

我要显示的项目都是我在根节点下的“showcaseFolder”下创建的“showcaseItem”文档类型。

我想从每个showcaseItem显示的属性是:

dojangName - textstring

dojangUrl - textstring

dojangDescription - 简单编辑器

dojangImage - 图像选择器(来自媒体)

看 - 显然我迷路了,理想情况下这是我希望提供的“那种”信息......

<li>
<div class="showbox"><a href="http://@showcaseItem.dojangUrl" target="blank">showcaseItem.dojangName</a>
<div class="showbox-inner">
<p>showcaseItem.dojangDescription</p>
<div class="showbox-image"><img src="showcaseItem.dojangImage" width=110px height=110 />    </div>
</div>
<a href="http://@showcaseItem.dojangUrl" target="blank">Click to Visit</a>
</div></li>

但我只是不知道从哪里开始这样我才能:

  1. 列出父文件夹下的每个孩子
  2. 将列表限制为随机更改的5个项目(愿望项目)
  3. 有人可以帮忙吗?

    查看我的虚拟网站http://propertymj.com(仅限chrome或firefox)。

1 个答案:

答案 0 :(得分:0)

这样的事情应该有效:

@{
// Get showcaseFolder:
var showcaseFolder = Library.NodeById(folderId);

// For debugging, output the name:
@showcaseFolder.Name

// Get five children at random:
var showcaseItems = showcaseFolder.Children.Random(5);

// For debugging, output the count:
@showcaseItems.Count()

// Iterate through items:
<ul>
@foreach (var item in showcaseItems)
{
    <li>
        <div class="showbox"><a href="http://@item.dojangUrl" target="blank">@item.dojangName</a>
            <div class="showbox-inner">
                <p>@item.dojangDescription</p>
                <div class="showbox-image"><img src="@Library.MediaById(item.dojangImage).umbracoFile" width=110px height=110 /></div>
            </div>
            <a href="http://@item.dojangUrl" target="blank">Click to Visit</a>
        </div>
    </li>
}
</ul>
}

在了解有关Umbraco Razor语法的更多信息时,请查看this answer获取一些有用的资源。