MBurger Headless CMS
User GuideCMS HeadlessEngagement Platform
  • 🍔MBurger Documentation🍔
  • 🔑 API
    • Introduction
      • Getting Started
      • Structure
    • Common Path
      • Basics
      • POST Bodies
      • POST Relations
      • Evaluating Responses
    • API Authentication
    • Project
    • Blocks
      • Get Blocks
      • Get Block
    • Sections
      • Get Sections
      • Get Section
      • Create Section
      • Update Section
      • Delete Section
    • Media
      • Get All Media
      • Upload Media
      • Get Media
      • Delete Media
    • Integrations / Extensions
      • Authentication Provider
        • Registration
        • Login
        • Logout
        • Get Profile
        • Update Profile
        • Delete Profile
        • Change Password
        • Forgot Password
      • Live Messages
        • Get All Live Messages
        • Send Live Message
        • Delete Live Message
      • In-App Subscriptions
        • InApp Subscription
        • Resume InApp Subscription
      • Shopify
        • Create a Shopify private app
        • Enable Shopify in MBurger
        • Collections Editor
      • Stripe
        • Create Customer
        • Get Cards
        • Create Card
        • Make Default
        • Delete Card
        • Subscription
        • Cancel Subscription
        • Resume Subscription
        • Payment
    • Going Deeper
      • Available Data Types (Elements)
  • 📱 Android SDK
    • Introduction
    • Installation
    • Initialization
    • Fetch for blocks
    • Fetch sections from blocks
    • Mapping to custom objects
    • Admin
      • Delete a Section/Media
      • Create a new Section
      • Update an existing Section
    • Auth
      • Register a new user
      • Authenticate a user
      • User profile
      • Edit profile
      • Other features
    • Proguard Rules
    • Plugins
    • Sample Apps
      • MBurger Explorer
      • MBurger Radio
    • MBurger Apps
  • 🍏 iOS SDK
    • Introduction
    • Installation
    • Initialization
    • Fetch the project
    • Fetch blocks
    • Fetch sections
    • Media
    • Encoding & Decoding
    • Serialization & Equality
    • Admin
      • Add/Edit a section
      • Delete a section
      • Upload media
      • Delete a media
    • Auth
      • Register a user
      • Authenticate a user
      • Retrieve user information
      • Update user profile
    • Plugins
    • Sample Apps
      • MBurger Explorer
      • MBurger Radio
    • MBurger Apps
  • 💻 PHP SDK
    • Installation & Configuration
    • How to use
    • Support & Feedback
    • License
  • ☕ JavaScript SDK
    • Introduction
    • Installation
    • Configuration
    • Methods Reference
    • Support & Feedback
    • License
  • 🔷Flutter SDK
    • Installation
    • Initialization
    • Fetch the project
    • Fetch blocks
    • Fetch sections
    • Media
    • Admin
      • Add/Edit a section
      • Delete a section
      • Upload a media
      • Delete a media
    • Auth
      • Register a user
      • Authenticate a user
      • Retrieve user information
      • Update user profile
  • ❓How to?
    • Basic interactions
      • Blocks
        • Get a Single Block
        • Get multiple Blocks
      • Sections
        • Get a single Section
        • Get Multiple Sections
        • Create a Section
        • Update a Section
        • Delete a Section
    • Advanced section retrieval
      • Filter sections
      • Obtain distance from a section
      • Manage locales and the fallback language
      • Get a section by SLUG
      • Obtain only sections with a defined relation
    • Advanced section creation
      • Create a section with a relation
      • Set the value of a checkbox element
      • Create a section with a multiple or dropdown element
      • Create a section with a SLUG
      • Create a section with SEO
      • Send or schedule a push when creating a section
    • Set the visibility of a section
    • Get images with various format
  • 👻 Sample App
    • Introduction
    • Create an MBurger project
    • Create Home, News and Gallery blocks
    • Create the project
    • Setup the SDK
    • Query the API for items
    • Map your objects from MBurger objects
    • Implement push notifications
    • Take a bite
Powered by GitBook
On this page
  • Filter by value
  • Filter by an element value
  • Filter by relation
  • Filter by geofence
  • Filter by id

Was this helpful?

  1. How to?
  2. Advanced section retrieval

Filter sections

Filter by value

curl https://mburger.cloud/api/blocks/<id>/sections?filter[value]=example_value
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
let filterParameter = MBFilterParameter(field: "value",
                                        value: THE_VALUE)
MBClient.getSections(ofBlock: BLOCK_ID,
                     parameters: [filterParameter],
                     success: { sections in
                                
                     },
                     failure: { error in
                                
                     })
val arrayFilters = ArrayList<Any>()
filters.add(MBFilterParameter(key = THE_KEY, value = THE_VALUE))

val sectionsListener = object: MBSectionsResultListener{
            override fun onSectionsApiError(error: String) {
            }

            override fun onSectionsApiResult(sections: ArrayList<MBSection>, 
                                             block_id: Long, 
                                             paginationInfos: MBPaginationInfo) {
            }
        }
        
MBurgerTasks.askForSections(context = applicationContext, 
                         block_id = BLOCK_ID,
                         filters = arrayFilters,
                         getElements = true,
                         listener = sectionsListener)
$response = (new MBurger())->getSections($block_id)->filterByValue(array $values, string $element_name = null);
const mburger = require('mburger');

const instance = mburger.createClient({
    api_key: "123456789asdfghj",
});

instance.getBlock({
    block_id: 799,
    filter: {
        'value': 'flowers'
    }
}).then(result => console.log(result));
MBFilterParameter filterParameter = MBFilterParameter(
  field: 'value',
  value: THE_VALUE,
);

MBPaginatedResponse<MBSection> sections =
    await MBManager.shared.getSections(
  blockId: BLOCK_ID,
  parameters: [filterParameter],
);

Filter by an element value

curl https://mburger.cloud/api/blocks/<id>/sections?filter[element.value]=example_value
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
let filterParameter = MBFilterParameter(field: "value",
                                        name: ELEMENT_NAME,
                                        value: THE_VALUE)
MBClient.getSections(ofBlock: BLOCK_ID,
                     parameters: [filterParameter],
                     success: { (sections, paginationInfo) in
                                
                     },
                     failure: { error in
                                
                     })
val arrayFilters = ArrayList<Any>()
filters.add(MBElementFilterParameter(element_name= THE_ELEMENT_NAME, 
                                 value = THE_VALUE))

val sectionsListener = object: MBSectionsResultListener{
            override fun onSectionsApiError(error: String) {
            }

            override fun onSectionsApiResult(sections: ArrayList<MBSection>, 
                                             block_id: Long, 
                                             paginationInfos: MBPaginationInfo) {
            }
        }
        
MBurgerTasks.askForSections(context = applicationContext, 
                         block_id = BLOCK_ID,
                         filters = arrayFilters,
                         getElements = true,
                         listener = sectionsListener)
// Work in progress
const mburger = require('mburger');

const instance = mburger.createClient({
    api_key: "123456789asdfghj",
});

instance.getBlock({
    block_id: 799,
    filter: {
        'value': 'element_name|element_value'
    }
}).then(result => console.log(result));
MBFilterParameter filterParameter = MBFilterParameter.named(
  field: 'value',
  name: ELEMENT_NAME,
  value: THE_VALUE,
);

MBPaginatedResponse<MBSection> sections =
    await MBManager.shared.getSections(
  blockId: BLOCK_ID,
  parameters: [filterParameter],
);

Filter by relation

curl https://mburger.cloud/api/blocks/<id>/sections?filter[relation]=<block_id>,<section_id>
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
let filterParameter = MBFilterParameter(field: "relation",
                                        value: RELATION_BLOCK_ID + "," + RELATION_SECTION_ID)
MBClient.getSections(ofBlock: BLOCK_ID,
                     parameters: [filterParameter],
                     success: { (sections, paginationInfo) in
                                
                     },
                     failure: { error in
                                
                     })
val arrayFilters = ArrayList<Any>()
filters.add(MBFilterParameter(key = "relation", 
                                 value = RELATION_BLOCK_ID 
                                 + "," + RELATION_SECTION_ID))

val sectionsListener = object: MBSectionsResultListener{
            override fun onSectionsApiError(error: String) {
            }

            override fun onSectionsApiResult(sections: ArrayList<MBSection>, 
                                             block_id: Long, 
                                             paginationInfos: MBPaginationInfo) {
            }
        }
        
MBurgerTasks.askForSections(context = applicationContext, 
                         block_id = BLOCK_ID,
                         filters = arrayFilters,
                         getElements = true,
                         listener = sectionsListener)
$response = (new MBurger())->getSections($block_id)->filterByRelation(int $block_id, int $section_id);
const mburger = require('mburger');

const instance = mburger.createClient({
    api_key: "123456789asdfghjk",
});

instance.getBlock({
    block_id: 798,
    filter: {
        'relation': 'RELATION_BLOCK_ID,RELATION_SECTION_ID'
    }
}).then(result => console.log(result));
MBFilterParameter filterParameter = MBFilterParameter(
  field: 'relation',
  value: RELATION_BLOCK_ID + ',' + RELATION_SECTION_ID,
);

MBPaginatedResponse<MBSection> sections =
    await MBManager.shared.getSections(
  blockId: BLOCK_ID,
  parameters: [filterParameter],
);

Filter by geofence

curl https://mburger.cloud/api/blocks/<id>/sections?filter[geofence]=latNE,latSW,lngNE,lngSW
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
let geofenceParameter = MBGeofenceParameter(NECoordinate: CLLocationCoordinate2D(NELat, NELng),
                                            SWCoordinate: CLLocationCoordinate2D(SWLat, SWLng))
MBClient.getSections(ofBlock: BLOCK_ID,
                     parameters: [geofenceParameter],
                     success: { (sections, paginationInfo) in
                                
                     },
                     failure: { error in
                                
                     })
}
val arrayFilters = ArrayList<Any>()
filters.add(MBGeofenceParameter(latitudeNE = yourLatitudeNE,
                                longitudeNE = yourLongitudeNE,
                                latitudeSW = yourLatitudeSW,
                                longitudeSW = yourLongitudeSW))

val sectionsListener = object: MBSectionsResultListener{
            override fun onSectionsApiError(error: String) {
            }

            override fun onSectionsApiResult(sections: ArrayList<MBSection>, 
                                             block_id: Long, 
                                             paginationInfos: MBPaginationInfo) {
            }
        }
        
MBurgerTasks.askForSections(context = applicationContext, 
                         block_id = BLOCK_ID,
                         filters = arrayFilters,
                         getElements = true,
                         listener = sectionsListener)
$response = (new MBurger())->getSections($block_id)->filterByGeofence(float $latNE, float $latSW, float $lngNE, float $lngSW);
MBGeofenceParameter parameter = MBGeofenceParameter(
  northEastLatitude: NELat,
  northEastLongitude: NELng,
  southWestLatitude: SWLat,
  southWestLongitude: SWLng,
);
    
MBPaginatedResponse<MBSection> sections =
    await MBManager.shared.getSections(
  blockId: BLOCK_ID,
  parameters: [parameter],
);

Filter by id

curl https://mburger.cloud/api/blocks/<id>/sections?filter[id]=example_id
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
/*
SECTION_ID can be a single id or a list of ids, comma separated.
*/
let filterParameter = MBFilterParameter(field: "id",
                                        value: SECTION_ID)
MBClient.getSections(ofBlock: BLOCK_ID,
                     parameters: [filterParameter],
                     success: { sections in
                                
                     },
                     failure: { error in
                                
                     })
val arrayFilters = ArrayList<Any>()
filters.add(MBFilterParameter(key = "id", 
                                 value = SECTION_ID))

val sectionsListener = object: MBSectionsResultListener{
            override fun onSectionsApiError(error: String) {
            }

            override fun onSectionsApiResult(sections: ArrayList<MBSection>, 
                                             block_id: Long, 
                                             paginationInfos: MBPaginationInfo) {
            }
        }
        
MBurgerTasks.askForSections(context = applicationContext, 
                         block_id = BLOCK_ID,
                         filters = arrayFilters,
                         getElements = true,
                         listener = sectionsListener)
$response = (new MBurger())->getSections($block_id)->filterByIds(array $ids);
const mburger = require('mburger');

const instance = mburger.createClient({
    api_key: "123456789asdfghjk",
});

instance.getBlock({
    block_id: 798,
    filter: {
        'id': '1,2,3'
    }
}).then(result => console.log(result));
/*
SECTION_ID can be a single id or a list of ids, comma separated.
*/
MBFilterParameter filterParameter = MBFilterParameter(
  field: 'id',
  value: SECTION_ID,
);
    
MBPaginatedResponse<MBSection> sections =
    await MBManager.shared.getSections(
  blockId: BLOCK_ID,
  parameters: [filterParameter],
);

PreviousAdvanced section retrievalNextObtain distance from a section

Last updated 4 years ago

Was this helpful?

❓