Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating site pages content - Hard or easy? #385

Open
PascalKremp opened this issue Oct 20, 2024 · 0 comments
Open

Updating site pages content - Hard or easy? #385

PascalKremp opened this issue Oct 20, 2024 · 0 comments

Comments

@PascalKremp
Copy link

    public function getPage($objectId)
    {
        try {
            return $this->client->cms()->pages()->sitePagesApi()->getById($objectId);
        } catch (ApiException $e) {
            echo 'Exception when calling site_pages_api->get_by_id: ', $e->getMessage();
        }
    }

    public function updatePage($objectId, Page $page)
    {
        try {
            return $this->client->cms()->pages()->sitePagesApi()->update($objectId, $page);
        } catch (ApiException $e) {
            return $e->getResponseBody();
            //            echo 'Exception when calling site_pages_api->update: ', $e;
        }
    }
    $hubSpot = hubSpot();

    $objectId = 1234;

    $page = $hubSpot->getPage($objectId);
    $page->setSlug('test-123');
    $page->setHtmlTitle('test-123');

    return $hubSpot->updatePage($objectId, $page);

Maybe I am having a wrong idea on how to update a page. But doing this returns couple of errors.

One error is for example that translations key has empty array. If I unset the translations key value pair from $page it works. But I need to remove some more to make it working.

Some best practices on how to use API for this case (updating page content) would be appreciated, espacially for layoutSections.

$page->update() would be nice after making some changes with setters. Maybe this is already included and I don't know about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant