Skip to main content

Searching for UGC

When setting up UGC in your game, you'll want users to be able to search for UGC before they subscribe to and install it.

This guide covers:

Querying UGC

The primary way this is done is through ListAllModsAsync. Note that authentication is not required to browse UGC.


Modio::ListAllModsAsync(Modio::FilterParams(), [](Modio::ErrorCode ec, Modio::Optional<Modio::ModInfoList> Results)
{
if (ec)
{
// Error handling
}
else
{
for (Modio::ModInfo& CurrentModProfile : *Results)
{
std::cout << CurrentModProfile.ProfileName;
}
}
});

You'll notice that ListAllModsAsync takes a FilterParams object as its first parameter. The default state of this object is set to ask for the first 100 results (the maximum number returnable in a query), sorting by the UGC's mod ID.

To search for a specific query string, sort in a different order, or combine different filters, you can pass in a FilterParams object like this:

// Search queries
Modio::ListAllModsAsync(Modio::FilterParams().NameContains("SomeString"), ...)
// Sorting
Modio::ListAllModsAsync(Modio::FilterParams().SortBy(Modio::FilterParams::SortFieldType::DownloadsToday, Modio::SortDirection::Ascending), ...)

// Ranged results - starting at index 20, return 10 results
Modio::ListAllModsAsync(Modio::FilterParams.NameContains("Your Query").IndexedResults(20, 10), ...)

// Ranged results - return the 20th page of 10 results
Modio::ListAllModsAsync(Modio::FilterParams.NameContains("Your Query").PagedResults(20, 10), ...)

Featuring Content

Game admins can configure Featured Content on their Game Dashboard on the mod.io website. Featured Content allows you to curate specific groups of UGC, such as "Trending this week", "Staff Picks" or even themed event content such as "Top Halloween Content", that you can use to feature specific content in your game's UI, for example as carousels on a home or discovery screen. These curated groups (called Placements) translate to FilterParams that you can pass directly to ListAllModsAsync.

Each Placement carries everything you need to build and render one of these curated sections:

  • Name (and localized variant NameLocalized), to use as a heading
  • DisplayPosition, indicating the order Placements should be displayed in relative to each other
  • Size (Small, Medium, or Large), a hint for how prominently the Placement can be displayed
  • Total, the number of results the Placement should show
  • bEnabled - disabled Placements should not be displayed
  • Filters, a FilterParams object describing which mods should populate the Placement

Placements are returned as part of GetGameInfoAsync.

Modio::GetGameInfoAsync(Modio::GameID(YourGameID), [](Modio::ErrorCode ec, Modio::Optional<Modio::GameInfo> Info)
{
if (ec)
{
// Error handling
}
else
{
CurrentPlacements = Info->Placements;
}
});

For each enabled Placement you want to display, pass its Filters to ListAllModsAsync to fetch the mods to show, limiting the number of results returned to Total:

for(const Modio::Placement& Placement : CurrentPlacements)
{
Modio::ListAllModsAsync(Placement.Filters, [](Modio::ErrorCode ec, Modio::Optional<Modio::ModInfoList> Results)
{
if (ec)
{
// Error handling
}
else
{
// Print the Localized name of the Placement
std::cout << Placement.NameLocalized;

for (Modio::ModInfo& CurrentModProfile : *Results)
{
std::cout << CurrentModProfile.ProfileName;
}
}
});
}

Next steps

Now your users can find UGC in your game, so it's time to set up the ability to subscribe to and download UGC using the Subscribing to UGC guide.

If you've already done this, we recommend working your way through the C++ SDK Getting Started Guides as they will teach you how to implement the mod.io fundamentals before moving onto exploring our Features.