YAFLogo

dev11
  • dev11
  • 54.8% (Neutral)
  • YAF Forumling Topic Starter
13 years ago
how we can get BoardID in code, if we have Board Name
Sponsor
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
13 years ago

how we can get BoardID in code, if we have Board Name

Originally Posted by: dev11 

Did you want to get the Current Board ID?

you can simple use

YafContext.Current.PageBoardID
dev11
  • dev11
  • 54.8% (Neutral)
  • YAF Forumling Topic Starter
13 years ago
No actually i have board name and i want to get boardID by passing this or using this boardName information.

is there any method or function of YAF API which returns boardID if we supply boardname ?

Thanks

bbobb
  • bbobb
  • 100% (Exalted)
  • YAF Developer
13 years ago
LegacyDB.board_list(...); then filter it by name.
thienvc
  • thienvc
  • 54.8% (Neutral)
  • YAF Forumling
13 years ago

[quote=dev11;51417]how we can get BoardID in code, if we have Board Name

Originally Posted by: tha_watcha 

Did you want to get the Current Board ID?

you can simple use

YafContext.Current.PageBoardID[/code][/quote]

im using yafDNN, im create 3 boards. and using the board with id = 3 (BoardId = 3).
an error occurs when do addThank. im debug and see BoardID in AddThanks in webservice is not same current boardid of forum.

[code=csharp]public ThankYouInfo AddThanks([NotNull] object msgID)
        {
            var messageID = msgID.ToType<int>();
            string username =
              LegacyDb.message_AddThanks(
                UserMembershipHelper.GetUserIDFromProviderUserKey(Membership.GetUser().ProviderUserKey), messageID);

            // if the user is empty, return a null object...
            return username.IsNotSet()
                     ? null
                     : YafThankYou.CreateThankYou(username, "BUTTON_THANKSDELETE", "BUTTON_THANKSDELETE_TT", messageID);
        }

//UserMemberShipHelper
public static int GetUserIDFromProviderUserKey(object providerUserKey)
    {
        int boardID = YafContext.Current.PageBoardID; //PageBoardID in here is not valid

      int userID = LegacyDb.user_get(boardID, providerUserKey.ToString());
      return userID;
    }

The YafContext.Current object in yafAjax is diffirence in another place?

How i can pass BoardId from current Board to the method in yafAjax or yafWebservice!? (not need using Config.BoardId)

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
13 years ago

How i can pass BoardId from current Board to the method in yafAjax or yafWebservice!? (not need using Config.BoardId)

Are You trying to use the Thank Function from the Webservice Manually, or did you use the Thanks Button? This Function will ONLY work from the Thanks Button.

thienvc
  • thienvc
  • 54.8% (Neutral)
  • YAF Forumling
13 years ago

How i can pass BoardId from current Board to the method in yafAjax or yafWebservice!? (not need using Config.BoardId)

Originally Posted by: tha_watcha 

Are You trying to use the Thank Function from the Webservice Manually, or did you use the Thanks Button? This Function will ONLY work from the Thanks Button.

i use the Thanks Button, but error occurs.

i think yafContext.Current in yafAjax is run out of the httpcontext of forum.

thienvc
  • thienvc
  • 54.8% (Neutral)
  • YAF Forumling
13 years ago
i have quesion, is yafDNN module can run with multi board in multi portal!?

if i change BoardID = 9999 in web.config, error occurs when click Thanks button for all forum instance if have boardID > 1.

i try debug then see BoardID in yafContext.Current has value 9999 from web.config. Why not getting BoardID from ModuleSetting!??!

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
13 years ago

i have quesion, is yafDNN module can run with multi board in multi portal!?

if i change BoardID = 9999 in web.config, error occurs when click Thanks button for all forum instance if have boardID > 1.

i try debug then see BoardID in yafContext.Current has value 9999 from web.config. Why not getting BoardID from ModuleSetting!??!

Originally Posted by: thienvc 

Yes i can reproduce this, with the BoardID in the Web.config.

What happens when you remove the Entry from the web.config.