OVH Cloud OVH Cloud

[SPS 2003] Récupération d'ID

5 réponses
Avatar
Joe L. F.
Bonjour

Comment récupérer l'ID de la zone en cours à partir d'un WebPart ?
A partir de l'objet PortalContext ?

5 réponses

Avatar
Renaud COMTE [MVP]
Effectivement

Voici un petit Sample qui devrais vous aider

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
//Get the current area GUID from the webpart
Guid objCurrentAreaGuid =
AreaManager.GetSystemAreaGuid(PortalContext.Current, SystemArea.Topics);

//Get an area object of the current area
Area objArea = AreaManager.GetArea(PortalContext.Current, objCurrentAreaGuid);

//Get the parent area GUID and make that an area object
Guid objParentAreaGuid = objArea.ParentID;
Area objParentArea = AreaManager.GetArea(PortalContext.Current,
objParentAreaGuid);

//Writes the details of the current area
output.Write(" This area is called " +objArea.Title +" <BR>" );
output.Write(" The parent area is called " +objParentArea.Title +" <BR>" );

//Gets the sub-areas of the parent into a collection and writes out each name
foreach (Area objSiblingArea in objParentArea.Areas)
{
output.Write(" Sibling: " +objSiblingArea.Title +" <BR>" );
}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Renaud COMTE [MVP]
Avatar
Joe L. F.
Merci pour l'exemple.
Maintenant je souhaiterais récupérer les sous-zones d'une zone dans le même
ordre défini dans le gestionnaire de site. Si j'itère sur la collection Areas
de la classe Area, j'obtiens les sous-zones triées par ordre alphabetique

"Renaud COMTE [MVP]" a écrit :

Effectivement

Voici un petit Sample qui devrais vous aider

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
//Get the current area GUID from the webpart
Guid objCurrentAreaGuid =
AreaManager.GetSystemAreaGuid(PortalContext.Current, SystemArea.Topics);

//Get an area object of the current area
Area objArea = AreaManager.GetArea(PortalContext.Current, objCurrentAreaGuid);

//Get the parent area GUID and make that an area object
Guid objParentAreaGuid = objArea.ParentID;
Area objParentArea = AreaManager.GetArea(PortalContext.Current,
objParentAreaGuid);

//Writes the details of the current area
output.Write(" This area is called " +objArea.Title +" <BR>" );
output.Write(" The parent area is called " +objParentArea.Title +" <BR>" );

//Gets the sub-areas of the parent into a collection and writes out each name
foreach (Area objSiblingArea in objParentArea.Areas)
{
output.Write(" Sibling: " +objSiblingArea.Title +" <BR>" );
}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Renaud COMTE [MVP]



Avatar
Renaud COMTE [MVP]
Et bien quelle curiosité !!!

Faut un peu chercher si on veut trouver ;)

Bon je jette vite un oeil dans le RSK et le MSDN

alors ...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/cArea.asp

Une fois le portal context de charger , je pense qu'il faut recuperer
l'ensemble des Area dans un collection puis vous effectuer un tri
personnlaiser via une classe implementant Icomparable pour comparer la
propriété "Order"

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/pAreaOrder.asp

(ou vous utiliser un sortedlist au pire )

Voila

Bon developpement

Renaud COMTE [MVP]


"Joe L. F." a écrit :

Merci pour l'exemple.
Maintenant je souhaiterais récupérer les sous-zones d'une zone dans le même
ordre défini dans le gestionnaire de site. Si j'itère sur la collection Areas
de la classe Area, j'obtiens les sous-zones triées par ordre alphabetique

"Renaud COMTE [MVP]" a écrit :

> Effectivement
>
> Voici un petit Sample qui devrais vous aider
>
> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
> //Get the current area GUID from the webpart
> Guid objCurrentAreaGuid =
> AreaManager.GetSystemAreaGuid(PortalContext.Current, SystemArea.Topics);
>
> //Get an area object of the current area
> Area objArea = AreaManager.GetArea(PortalContext.Current, objCurrentAreaGuid);
>
> //Get the parent area GUID and make that an area object
> Guid objParentAreaGuid = objArea.ParentID;
> Area objParentArea = AreaManager.GetArea(PortalContext.Current,
> objParentAreaGuid);
>
> //Writes the details of the current area
> output.Write(" This area is called " +objArea.Title +" <BR>" );
> output.Write(" The parent area is called " +objParentArea.Title +" <BR>" );
>
> //Gets the sub-areas of the parent into a collection and writes out each name
> foreach (Area objSiblingArea in objParentArea.Areas)
> {
> output.Write(" Sibling: " +objSiblingArea.Title +" <BR>" );
> }
>
> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
>
> Renaud COMTE [MVP]
>


Avatar
Damien MINART
Je suis intéressé par ce genre de fonction j'ai donc essayé ce code
malheureusement j'ai un message d'erreur :

cateogry not found

a priori sur la première ligne :
//Get the current area GUID from the webpart
Guid objCurrentAreaGuid =
AreaManager.GetSystemAreaGuid(PortalContext.Current, SystemArea.Topics);



(oui, oui avec la faute de frappe)

Savez-vous d'où cela peut-il venir ?


"Renaud COMTE [MVP]" a écrit :

Effectivement

Voici un petit Sample qui devrais vous aider

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
//Get the current area GUID from the webpart
Guid objCurrentAreaGuid =
AreaManager.GetSystemAreaGuid(PortalContext.Current, SystemArea.Topics);

//Get an area object of the current area
Area objArea = AreaManager.GetArea(PortalContext.Current, objCurrentAreaGuid);

//Get the parent area GUID and make that an area object
Guid objParentAreaGuid = objArea.ParentID;
Area objParentArea = AreaManager.GetArea(PortalContext.Current,
objParentAreaGuid);

//Writes the details of the current area
output.Write(" This area is called " +objArea.Title +" <BR>" );
output.Write(" The parent area is called " +objParentArea.Title +" <BR>" );

//Gets the sub-areas of the parent into a collection and writes out each name
foreach (Area objSiblingArea in objParentArea.Areas)
{
output.Write(" Sibling: " +objSiblingArea.Title +" <BR>" );
}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Renaud COMTE [MVP]



Avatar
Joe L. F.
J'ai utilisé finalement cette ligne pour récupérer l'ID :

guidCurrentArea = SPControl.GetContextWeb(Context).ID;



"Damien MINART" a écrit :

Je suis intéressé par ce genre de fonction j'ai donc essayé ce code
malheureusement j'ai un message d'erreur :

cateogry not found

a priori sur la première ligne :
//Get the current area GUID from the webpart
> Guid objCurrentAreaGuid =
> AreaManager.GetSystemAreaGuid(PortalContext.Current, SystemArea.Topics);

(oui, oui avec la faute de frappe)

Savez-vous d'où cela peut-il venir ?


"Renaud COMTE [MVP]" a écrit :

> Effectivement
>
> Voici un petit Sample qui devrais vous aider
>
> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
> //Get the current area GUID from the webpart
> Guid objCurrentAreaGuid =
> AreaManager.GetSystemAreaGuid(PortalContext.Current, SystemArea.Topics);
>
> //Get an area object of the current area
> Area objArea = AreaManager.GetArea(PortalContext.Current, objCurrentAreaGuid);
>
> //Get the parent area GUID and make that an area object
> Guid objParentAreaGuid = objArea.ParentID;
> Area objParentArea = AreaManager.GetArea(PortalContext.Current,
> objParentAreaGuid);
>
> //Writes the details of the current area
> output.Write(" This area is called " +objArea.Title +" <BR>" );
> output.Write(" The parent area is called " +objParentArea.Title +" <BR>" );
>
> //Gets the sub-areas of the parent into a collection and writes out each name
> foreach (Area objSiblingArea in objParentArea.Areas)
> {
> output.Write(" Sibling: " +objSiblingArea.Title +" <BR>" );
> }
>
> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
>
> Renaud COMTE [MVP]
>