fast implementation of a news block / #3649

For the new project page at www.streber-pm.org pixtur wrote a new version of the projView Page. Changes:
  • Newslist
  • no Folders
  • no Teamlist
Listing News is actually very easy. News are "Documation Pages" with label Number 1 ("important" in this case). This is the complete code for rendering the news block:

from pages/custom_projView.inc.php

    #--- news -----------------------------------------------------------
    {
        if($news= Task::getAll(array(
            'category'  => TCATEGORY_DOCU,
            'label'     => 1,
            'order_by'  => 'created DESC',
        ))) {
            
            $block=new PageBlock(array(
                'title'=>__('News'),
                'id'=>'news',
                #'reduced_header'=>true,
    
            ));
            $block->render_blockStart();
    
            #echo $str;
    
            echo "<div class='text'>";
            
            $count = 0;
            foreach($news as $n) {
                if($count++ >= 3) {
                    break;
                };
                echo "<div class='newsBlock'>";
                if($creator= Person::getVisibleById($n->created_by)) {
                    $link_creator= ' by '. $creator->getLink();
                }
                echo "<div class=newsTitle><h3>".$PH->getLink('taskView', $n->name , array('tsk' => $n->id)) ."</h3><span class=author>". renderDateHtml($n->created) . $link_creator . "</span></div>";
                echo wiki2html($n->description, $project);
                
                echo "<span class=comments>";
                if($comments= $n->getComments()) {
                     echo  $PH->getLink('taskViewAsDocu', sprintf(__("%s comments"),count($comments)), array('tsk'=> $n->id));
                }
                echo " | ";
                echo $PH->getLink("commentNew", __("Add comment"), array('parent_task' => $n->id) );
                echo "</span>";
                
                echo "</div>";                
            }   
            echo "</div>";
    
            $block->render_blockEnd();
        }

    }




also see:

16 Comments

burger

Jan 11, 2007
version 2
Question
I saw this feature at the custom_projectview.inc.php.
But how can I use this custom_projectview?
What's the sense of this view?

Futher I would like to now if everybody should have the new labels like "important", "3d" etc?
Or can everybody have it's own labels in it's local streber?

I ask this because we still have the old labeling like "Enhancement", "Refactor", etc. and cannot set the docu to "important" like you describe above.

pixtur

Jan 11, 2007
sorry. Documenation was incomplete...
I added some more details at the text. The purpose for the custom_projectView was the new streber page at www.streber-pm.org .

For using customized pages see Overwriting pages with customized versions

The name of the label is not important. It's the 1. position on the list after Undefined.

burger

Jan 12, 2007
Thanks for your answer
Your more detailed description helped me to test this new feature. Thanks :-).

But I have one annotation:

All docus are shown at every project view. But it would be great if only the related docus of a project would be displayed at the specific project view.

Can you implement it like this or do you have a reason why all docus are shown at every project view?

pixtur

Feb 12, 2007
ups... I missed this...
Hi Burger,

obviously I overlooked your last comment. This would obviously be a bug. Are you talking about the customized proj_view? I only tested this with streber-pm.org are we only have one project here...


cvivanco

Feb 16, 2007
Add or remove users window disapeared
After implementing this, there is no way to remove a person from the project, you can still add a member though. It would be nice to activate/deactivate user from projects from the add Team Member window from the project view.

pixtur

Feb 16, 2007
it's custom :)
Well, this implementation was meant for www.streber-pm.org only. The team list has been intentially left out, because we do not need the team list on this site.

Of couse it should be displayed when used within a normal environment :)

guest

Mar 15, 2007
Fixed bug "show news for current project only"
Hi,

I just wanted to let you know that there's a little bug in the code mentioned above! It gets ALL tasks defined as news from db but actually we just want to have the news for the current project.

from pages/custom_projView.inc.php

    #--- news -----------------------------------------------------------
    {
// 20070314 AHE: Fixed bug "show only news for current project"
// OLD CODE
//        if($news= Task::getAll(array(
// NEW CODE
        if($news= $project->getTasks(array(
            'category'  => TCATEGORY_DOCU,
            'label'     => 1,
            'order_by'  => 'created DESC',
        ))) {

Greets,

pixtur

Mar 15, 2007
good hint...
Thanks for mentioning.

burger

May 9, 2007
Another bug
Can someone please change the code line the guest user mentioned at 15 March 2007? It's still the old version in the svn repository.
Furthermore the codeline with label => 1 is wrong. Label 1 stands for Bug and that's not the correct notation for News . Or am I wrong?
Maybe we should initiate a new label called News? What do you think about this?

krisp

May 9, 2007
Label News
I am in but I'd rather call it Info than News.

burger

May 9, 2007
version 3
Another bug
Some parts of the file custom_projectView.inc.php are obsolete. There is, for example, still the old code to show the changes and the description block is missing.

I know that the news block was originally designed for the usage at www.streber-pm.org only, but this block can be useful for "normal" projects, too. Therefore it would be great if the file custom_projectView.inc.php would be in the general identical with the project_view.inc.php file (expect of the news block). Or the news block should be included in the project_view.inc.php with e.g. a customize-option in the customize.inc.php file.
What do you think?

pixtur

May 9, 2007
I already changed the code here.
So maybe it was more a problem of the old documentation at this Topic.

Yeah, the news feature has been proven to be quiet useful. Using the Label was just a hack at www.streber-pm.org. Note that labels are project specific and different from project to project. So having a new Label-Name is probable not the best idea. Maybe we should add a new Display-Setting for this? But while doing this we could also distinguish between project news and news that are more important and listed in "home". Or is this overdone?


krisp

May 11, 2007
I think we need more than label...
For example, I need to distinguish tasks from Infos and Discussions the same way as a Docu, Folder or Bug are.

Particularly concerning Discussion, I see it as a Docu like object but seen on tasks list with label Discussion, having people assigned (involved) in it but not being task on their task list (a separate list at home). What do you think?

pixtur

May 14, 2007
sounds overdone...
Maybe I am not getting your request completely.
  1. You can already assign people to documentation tasks, but I have no idea, what to do with this information. (Maybe use for filters later).
  2. I am looking format for Request feedback of persons on items which will be a nice way for involving certain people into a discussion.
  3. Documentation Topics are already separated from tasks.

krisp

May 14, 2007
version 2
Reply to sounds overdone...
Ad.1. OK, but in 2 steps: 1) Make task and assign people 2) Make docu. If you want assign one more, you have to bring task back (2 more steps) - Ugh!
Furtermore, I said about steps, not clicks (quite more).

pixtur

May 14, 2007
So it's just about assignment?
The assignment thing will definitely change into an ajax driven method like in Request feedback of persons on items (see screen shot in the comments).

 

Comment / Update