how to make a link “read more” appear only if extended text is submitted in SAEF?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
July 20, 2007 5:22pm
Subscribe [4]#1 / Jul 20, 2007 5:22pm
how to make a link “read more” appear only if extended text is submitted in SAEF?
#2 / Jul 20, 2007 8:27pm
I think this is what you’re looking for…
put this into your
<head>tags
function showHide(entryID, entryLink, htmlObj, type) {
if (type == "comments") {
extTextDivID = ('comText' + (entryID));
extLinkDivID = ('comLink' + (entryID));
} else {
extTextDivID = ('extText' + (entryID));
extLinkDivID = ('extLink' + (entryID));
}
if( document.getElementById ) {
if( document.getElementById(extTextDivID).style.display ) {
if( entryLink != 0 ) {
document.getElementById(extTextDivID).style.display = "block";
document.getElementById(extLinkDivID).style.display = "none";
htmlObj.blur();
} else {
document.getElementById(extTextDivID).style.display = "none";
document.getElementById(extLinkDivID).style.display = "block";
}
} else {
location.href = entryLink;
return true;
}
} else {
location.href = entryLink;
return true;
}
}
function showMoreAnything(blocknum, isOpen) {
hid = ('hide' + (blocknum));
unhid = ('click' + (blocknum));
if(document.getElementById) {
if(document.getElementById(hid).style.display) {
if(isOpen !=0) {
document.getElementById(hid).style.display = "block";
document.getElementById(unhid).style.display = "none";
} else {
document.getElementById(hid).style.display = "none";
document.getElementById(unhid).style.display = "block";
}
} else {
location.href=isOpen;
return true;
}
} else {
location.href=isOpen;
return true;
}
}and put this where your extended entry text is…
Copy all VERBATIM…the javascript is very long so using an embedded template is pragmatic. 😊
#3 / Jul 20, 2007 10:50pm
The other option is to have code like this:
{if extended}
< a href="{path=templatename/template/url_title}">... Read More</a>
{/if}#4 / Jul 21, 2007 9:38am
Both are valid. I’ve used Bobby’s technique on a few sites. It works well. The Javascript code can go in as a global variable, so you’d do something like {js_readmore} (global variable) to get the Javascript in there.
#5 / Jul 21, 2007 1:57pm
If you want to carry this one step further there’s another aspect here. You can add an anchor in your comments template. So if someone clicks ‘read more’ it takes them right to the text in the extended area. That way they don’t have to scroll down to try to figure out where they left off from the front page.
I use this in conjunction with the process sue offered:
{if extended}
<a href="http://{title_permalink={template_group_name}/comments}#continued">Read More…</a>
{/if}Then in the comments template I have this:
{summary}
{body}
<a name="continued"></a>
{extended}#6 / Aug 17, 2007 2:48am
I didn’t realise there were other ways to do it, that was a way I found when I searched thru the EE forums for my knowledge.