Block article - Latest article, shown fully open

Discussion in 'Article Script / Article Directory Script' started by olairmarcos, May 22, 2016.

  1. olairmarcos

    olairmarcos Member

    I need to create a block to display only one item (latest article), but the item published on the site should be shown fully open.
    Thanks for the help.
  2. Vasily_B.

    Vasily_B. Project Manager


    Thanks for your request. I would do this as follows. Add this code to your <blocks> section in packages/publishing/install.xml file.
    Code (Text):

    <block name="latest_article" title="Latest article" position="bottom" type="smarty" header="0" filename="block.latest-article"><![CDATA[]]></block>
    Now you need a PHP code to fetch the latest article, check packages/publishing/includes/hook.blocks-load.php add this code:
    Code (Text):

        if ($iaView->blockExists('latest_article'))
            if ($latestArticle = $iaDb->getRow($sql . 'ORDER BY a.`date_added` DESC'))
            $iaView->assign('latestArticle', $latestArticle);
    And now just create a template file to print this. it should be packages/publishing/templates/common/block.latest-article.tpl
    Code (Text):

    That's it. You only need to display it as needed.
  3. olairmarcos

    olairmarcos Member

    Thank you for the reply, Vasily_B

    Well, the code proposed above did not work ...
    Shows only NULL in the Latest Article block

    Following your tip.
    I created a new block (in the install.xml file) called: View Latest Article

    I created a new file named in the packages/plublishing/templates/common: block.view-latest-article.tpl

    Add in the file: block.view-latest-article.tpl
    Code (Text):
    {_v($ ViewlatestArticle)}
    In the Add file: packages/publishing/includes/hook.blocks-load.php
    Add the following code:

    Code (Text):
    if ($iaView->blockExists('view_latest_article'))
            if ($viewlatestArticle = $iaDb->getRow($sql . 'ORDER BY a.`date_added` DESC'))
            $iaView->assign('viewlatestArticle', $viewlatestArticle);
    Now is opening the block (View Latest Block) on the site, is showing the values of the item, is not showing the page of the last item added to the site, fully open.
    See the result in the figure below.

    I appreciate your attention, wait.
    Last edited: May 25, 2016
  4. olairmarcos

    olairmarcos Member

    The function of this block is to show the newest article initially opened in this block on top, while below we have a list of other articles.

    I see that we can use the New Article block to show the newest article fully open on the site. To do this simply change the code to display the open item, and do not show the article summarized as standard.
    Last edited: May 24, 2016
  5. Vasily_B.

    Vasily_B. Project Manager

    The function of this block is to show the newest article initially opened in this block on top, while below we have a list of other articles.
    Hmm, I tried to find any other notable changes in your code except var names. It looks absolutely the same, not sure why mine didn't work for you, though it worked well for me :)

    Could you please clarify what you mean by this:
    Any chance to show this as an image? I don't understand what you mean.

    Ok, just make the position of your block as 'top', you can disable header if needed.

    And just print the value as {$latestArticle.description}

    To be honest, I'm kinda confused with your request. Are there several people using your account? :)
  6. olairmarcos

    olairmarcos Member

    Hello. Thanks for the answers. I'm sorry for the confusion.

    Let's start:
    I want to show within a block, the newest article published on the site, fully open, (not summarized as is standard) and I will put in the top position.

    We can also do the following:
    Show on page articles listing, the first article of the list fully open and the oldest show summarized

    I made the changes proposed by you, did not work. It appears in the word block: NULL
    There is no other people using my account. This is my test site.

    I created another block (View Latest Article) and put the proposed code with other variables, in this case the block appears in the "top" but does not show the fully open latest article on the site.
    The block shows the values of the page is not rendered.
    See (black block) in the image, it was what appeared within my block (View Latest Article) I created.

    Now showing:

    I want to appear like this:

    I like to see the sites, the newest article fully open, since the beginning, and the oldest articles a summary list. So visitors may read the article at the time.

    I found that the black block is shown when we keep the DEBUG mode active.
    When I turn off the DEBUG mode, the block does not appear on the site.

    Thank you for your patience to meet my difficulty.
    Last edited: May 26, 2016
  7. Vasily_B.

    Vasily_B. Project Manager

    Ok, so you need to display the very first article in the lists as full article and keep the rest going summarized. No need to use the method above, as you already have the information about the article you need. I would just update your cycle that lists articles and display full information during the first iteration.

    Here is the example:
    this page. You need Sistine Chapel article to show fully open. Right?

    In this case you'd need to update index.tpl in your packages folder. Find this cycle:
    {foreach $articles as $listing}

    add the following condition inside:
    {if [email protected]}
    here you should put your HTML code with the article
    {include file='extra:publishing/list-articles'}
    That's it. In this case it will show the article as you need, and the rest will be displayed summarized.
    olairmarcos likes this.

Share This Page