Show any article from the the site on Home Page

General web design discussion, including HTML, CSS, and JavaScript

Show any article from the the site on Home Page

Postby gsw28 » Mon Dec 17, 2012 12:32 pm

Hello,

My website has numerous articles but I would like to only feature a few of those articles on the home page. Is there a button or something that I can make with magic edit that will push articles to the home page. Right now I have 3 articles on the home page that are also featured elsewhere on the site. I would like to be able to show any 3 selected articles from the rest of the site on the homepage without having to hard-code those articles into the home page. - - I hope that makes sense.

Thanks!
gsw28
 
Posts: 8
Joined: Fri Dec 07, 2012 4:40 pm

Re: Show any article from the the site on Home Page

Postby raw10 » Mon Dec 17, 2012 1:01 pm

Well, the best way to do this is with a basic editable link area that lives on the home page. That way the content manager can edit that region to point to any page in the site. The only issue is that there is a bit of double entry going on. Here's a bit of code from a site that does this:

Code: Select all
<div cl_visible="=CLManager.activeAccount:isAdmin||$feature1Title">
  <img class="attachment-single_latest post-image" src="http://placehold.it/200x136&text=Add+Image" magicedit me_name="feature1Img" cl_effects="maxsize=200,136,1" cl_nosize cl_alt="$feature1Title" />
  <h5><a href="#" magicedit me_name="feature1Link">Feature Title</a></h5>
  <div class="meta" cl_visible="=CLManager.activeAccount:isAdmin||$feature1Sum">
    <p><magicedit me_name="feature1Sum" me_plain>Summary of the feature</magicedit></p>
  </div>
  <div class="cleared"></div>
</div>
<div class="single_latest left" cl_visible="=CLManager.activeAccount:isAdmin||$feature2Title">
  <img class="attachment-single_latest post-image" src="http://placehold.it/200x136&text=Add+Image" magicedit me_name="feature2Img" cl_effects="maxsize=200,136,1" cl_nosize cl_alt="$feature2Title" />
  <h5><a href="#" magicedit me_name="feature2Link">Feature Title</a></h5>
  <div class="meta" cl_visible="=CLManager.activeAccount:isAdmin||$feature2Sum">
    <p><magicedit me_name="feature2Sum" me_plain>Summary of the feature</magicedit></p>
  </div>
  <div class="cleared"></div>
</div>


Now you have a couple of "feature" areas that can be edited to do just about anything. You just need an image, a summary block (optional), and a page to link to. Clicking on the "edit" button next to the Feature Title lets you enter in the title and the link to an interior page (e.g. /My_Article_Name or /repeatPage/123).

That said, because of the very flexible nature of how MagicRepeat works, there is no way to show an arbitrary result as selected by the user. You can, however, automatically show just the first n results as sorted by the user or by when the item was created by using the me_maxitems option.
raw10
 
Posts: 81
Joined: Tue Apr 12, 2011 2:46 pm

Re: Show any article from the the site on Home Page

Postby gsw28 » Tue Dec 18, 2012 11:36 am

Ok cool Im almost there but how do I get it published??? I have uploaded this code to the site and I can edit it but when I log out of the site nothing shows up. - Please HELP!!
gsw28
 
Posts: 8
Joined: Fri Dec 07, 2012 4:40 pm

Re: Show any article from the the site on Home Page

Postby raw10 » Tue Dec 18, 2012 12:01 pm

Ah, that's what I get for posting up code without testing it. Looks like some of the cl_visible targets are messed up. Here's some cleaned up code with fixes. To replicate it for additional features just replace "1" with "2", "3", etc.

Code: Select all
<div cl_visible="=CLManager.activeAccount:isAdmin||$feature1Link">
  <img src="http://placehold.it/200x136&text=Add+Image" magicedit me_name="feature1Img" cl_effects="maxsize=200,136,1" cl_alt="$feature1sum" />
  <h5><a href="#" magicedit me_name="feature1Link">Feature Title</a></h5>
  <div class="meta" cl_visible="=CLManager.activeAccount:isAdmin||$feature1Sum">
    <p><magicedit me_name="feature1Sum" me_plain>Summary of the feature</magicedit></p>
  </div>
  <div class="cleared"></div>
</div>


Basically, there was actually no "feature1Title", so I'm replacing it with "feature1Link" instead, and then using the summary for the alt text on the image. Here's a quick explanation.

1. Only show the outer DIV if logged in as admin or feature1Link exists (has been edited).
2. Place an image that is automatically sized to a maximum of 200 by 136. To crop, replace "maxsize" with "zoom".
3. The link is editable, so the content manager can update it with whatever they want for a link and link text.
4. The summary is also optional, and will show up if logged in or it exists (has been edited).

Hope that helps.
raw10
 
Posts: 81
Joined: Tue Apr 12, 2011 2:46 pm


Return to Web Design

Who is online

Users browsing this forum: No registered users and 1 guest

cron