0
votes

Hi i have a web site on umbraco 4 CMS.Also i want to install a blog plugin.

Is there possible pull news from blog into my site.

Example i want to publish news/post everyday from blog and create link to blog page from my web site.

Preview :

web site

thx for ur help

1
Hi, I need some more information in order to help. The blog and the site are in different domains? Do you want to publish the posts manually or just to have them on your homepage automatically?benams
no its umbraco plugin and same domain.i want to use this blog4umbraco.codeplex.com/releases/view/42119#ReviewsAnchorMennan
I write my blog manually but i want to publish it automatically of courseMennan
I meant to ask if you want to select the posts which are displayed in your homepage manually, or you want a macro to do it? (for example a macro that will select the 5 newest posts)benams
i just started to umbraco sorry.I want to macro to do it.Mennan

1 Answers

0
votes

Something like this should work if you are using Blog4Umbraco. It requires that you have the source as a ContentPicker parameter and the maxItems as a number. It does some things like format the date for sorting properly and checking for posts in the past (in case they are scheduled).

<xsl:param name="currentPage"/>

<xsl:variable name="documentTypeAlias" select="string('BlogPost')"/>
<xsl:variable name="source" select="/macro/source"/>
<xsl:variable name="maxItems" select="/macro/maxItems" />


<xsl:template match="/">

  <xsl:variable name="currPosts" select="umbraco.library:GetXmlNodeById($source)//BlogPost [@isDoc and umbraco.library:DateDiff(@createDate, umbraco.library:CurrentDate(), 'm') &lt; 0]"/>


  <xsl:for-each select="$currPosts">
    <xsl:sort select="umbraco.library:FormatDateTime(@createDate, 'yyyyMMdd')" data-type="number" order="descending" />
    <xsl:if test="position() &lt;= $maxItems">
      <div>

        <h4><xsl:value-of select="@nodeName"/></h4>
        <span class="homeBlogDate"><xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'M.dd.yy')"/></span>
        <p>
          <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(bodyText), 140, ' ')" disable-output-escaping="yes"/>...
        </p>
        <a href="{umbraco.library:NiceUrl(@id)}" class="postReadMore">
          read more &gt;
        </a>
      </div>
    </xsl:if>
  </xsl:for-each>



</xsl:template>