short and long descriptions

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

short and long descriptions

cadet1620
Is there any way to have different sub-forum descriptions in the top level vs. the sub-forum itself?  I'd like to have a 3 or 4 word description at the top level and a multiline description at the top of the sub-forum itself.

I was playing around with NAML but haven't yet discovered how to change a sub-forum's displayed description.
Reply | Threaded
Open this post in threaded view
|

Re: short and long descriptions

cadet1620
There's likely a better way to do this, and I should have written a new macro to do the substitution, but since I only had one sub-forum that needed the alternate description I wrote it inline.

<override_macro name="app_body_header" requires="node_page,servlet">
    <n.page_node.>
        <table style="border-collapse:collapse;width:100%">
            <tr>
                <td id="forum-header" style="width:95%">
                    <h1 id="forum-title" class="app-title-[n.id/]"><n.subject/></h1>
                    <div id="description-box">
                        <n.mailing_list_information/>
++++++++++
                        <n.if.equal value1="[n.id/]" value2="3350163">
                            <then>
This is the very long winded description for the sub-forum with
node ID 3350163.  You can find the node ID by viewing the HTML
source for the sub-forum and searching for 'class="app-title-'
which is immediately followed by the node number.
                            </then>
                            <else><n.node_message_as_html/></else>
                        </n.if.equal>
----------
                        <n.node_message_as_html/>
==========
                    </div>
                    <span id="search-box" class="search-box" style="clear:both;white-space:nowrap">
                        <n.search_box/>
                    </span>
                </td>
            </tr>
        </table>
    </n.page_node.>
</override_macro> 
Reply | Threaded
Open this post in threaded view
|

Re: short and long descriptions

GregChapman
Just a thought about a more generic approach...

Check out "Custom summary for Newspaper" under OPTIONS > APPLICATION > EXTRAS & ADD-ONS.

You'll see that option enables a response to special {summary_start}...{summary_end} tags which you add to the body of a new topic.

While that add-on only works for newspaper applications, I guess it could well be possible to use a similar technique and create {short_start}... {short_end} tags for use across any application in the description field?
Volunteer Helper - but recommending that users move off the platform!
Once the admin for GregHelp now deleted.
Reply | Threaded
Open this post in threaded view
|

Re: short and long descriptions

GregChapman
Should have added...

I have a newspaper at:
http://www.gregafloat.plus.com/blog/index.html
which has this feature enabled.

Drill down to
view_news › view_news_page › news_page_layout › news_table › news_text_cell › news_snippet_row
and you should be close to the code that does the business.
Volunteer Helper - but recommending that users move off the platform!
Once the admin for GregHelp now deleted.
Reply | Threaded
Open this post in threaded view
|

Re: short and long descriptions

DavidJCobb
In reply to this post by cadet1620
A regex-based solution could also work. I haven't tested this, though, and I don't know what particular flavor of regex NAML uses. I'd recommend trying this on a test site before editing it into your mains. For places where the long description should be shown:
<n.regex_replace_all. pattern="\[short_desc\][^\b]+?\[/short_desc\]" replacement=" "><n.node_message_as_html/></n.regex_replace_all.>
For places where the short description should be shown:
<n.regex_replace_all. pattern="\[long_desc\][^\b]+?\[/long_desc\]" replacement=" "><n.node_message_as_html/></n.regex_replace_all.>
Example of how to format your description to work with the above:
[short_desc]This text is not shown for the long description.[/short_desc]
[long_desc]This text is not shown for the short description.[/long_desc]
This text isn't in one of our two fake tags, so it would show for either description.
Reply | Threaded
Open this post in threaded view
|

Re: short and long descriptions

cadet1620
Great idea.  I'll have to try it.

One must also remove the short/long tags from the version that is being displayed, as in:
<n.regex_replace_all. pattern="\[\\?long_desc\]" replacement=" ">
  <n.regex_replace_all. pattern="\[short_desc\][^\b]+?\[/short_desc\]" replacement=" "><n.node_message_as_html/></n.regex_replace_all.>
</n.regex_replace_all.>
Reply | Threaded
Open this post in threaded view
|

Re: short and long descriptions

DavidJCobb
cadet1620 wrote
Great idea.  I'll have to try it.

One must also remove the short/long tags from the version that is being displayed, as in:
<n.regex_replace_all. pattern="\[\\?long_desc\]" replacement=" ">
  <n.regex_replace_all. pattern="\[short_desc\][^\b]+?\[/short_desc\]" replacement=" "><n.node_message_as_html/></n.regex_replace_all.>
</n.regex_replace_all.>
The pattern in the outer regex macro is broken, but other than that, yeah, that'd work perfectly.
Reply | Threaded
Open this post in threaded view
|

Re: short and long descriptions

cadet1620
In reply to this post by cadet1620
I got David's regex idea working.  

 I could not figure out how to get '[' into the regex pattern parameter.  It appears that '[' has special meaning to NAML even within quoted parameters as in
    class="app-title-[n.id/]"
and I didn't find a way to quote it so I did without.

The usefulness of regular expressions is limited without [ ].  I hope there's a way to get them in there.


In "subcategories_column" macro I display the short description:
          <n.if.current_node.is_app>
----------
            <then.current_node.node_message_as_html/>
++++++++++
            <then>
              <n.regex_replace_all. pattern="\{/?short-desc\}" replacement=" ">       
                <n.regex_replace_all. pattern="\{long-desc\}.*\{/long-desc\}" replacement=" ">       
                  <n.current_node.node_message_as_html/>
                </n.regex_replace_all.>       
              </n.regex_replace_all.>
            </then>
==========
            <else>
In "app_body_header" macro I display the long description:
                    <div id="description-box">
                       <n.mailing_list_information/>
----------
                       <n.node_message_as_html/>
++++++++++
                       <n.regex_replace_all. pattern="\{/?long-desc\}" replacement=" ">
                         <n.regex_replace_all. pattern="\{short-desc\}.*\{/short-desc\}" replacement=" ">
                           <n.node_message_as_html/>
                         </n.regex_replace_all.>
                       </n.regex_replace_all.>
==========
                    </div>

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: short and long descriptions

DavidJCobb
cadet1620 wrote
The usefulness of regular expressions is limited without [ ].  I hope there's a way to get them in there.
Perhaps this? Haven't tried it.

<n.regex_replace_all>
   <pattern>[1-3]</pattern>
   <replacement>_</replacement>
   <text>1 2 3 4.  Numbers? What numbers? Those are underscores! Except the one on the right, anyway.</text>
</n.regex_replace_all>
Reply | Threaded
Open this post in threaded view
|

Re: short and long descriptions

cadet1620
It works to define macros containing the patterns with brackets
    <macro name="regex_short_tag">
      \[/?short-desc\]
    </macro>
 
    <macro name="regex_long_text">
      \[long-desc\].*?\[/long-desc\]
    </macro>
and then call them in the regex calls:
    <n.regex_replace_all. pattern="[n.regex_short_tag/]" replacement=" ">       
      <n.regex_replace_all. pattern="[n.regex_long_text/]" replacement=" ">  

--Mark