PHP code example of paxxion / craft-redirector

1. Go to this page and download the library: Download paxxion/craft-redirector library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paxxion / craft-redirector example snippets




use craft\elements\Entry;

$rows = [];

$sites = Craft::$app->sites->getAllSites();
foreach ($sites as $site) {
    $entries = Entry::find()->siteId($site->id)->all();
    foreach ($entries as $entry) {
        $url = $entry->getUrl();

        if ($url) {
            $rows[] = [
                'site' => $site->handle,
                'language' => $site->language,
                'title' => $entry->title,
                'description' => $entry->subtitle ?? '',
                'url' => $url,
            ];
        }
    }
}

return $rows;