PHP code example of tecnodesignc / adsense-module

1. Go to this page and download the library: Download tecnodesignc/adsense-module 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/ */

    

tecnodesignc / adsense-module example snippets


{-- Themes/MyTheme/views/space/my-own-space.blade.php --}
<div id="{{ $space->system_name }}" class="my-own-space-class">

    @foreach($space->ads as $index => $ad)
        <div class="ad">
            <a href="{{ $ad->getLinkUrl() }}">
                <img src="{{ $ad->getImageUrl() }}" />
            </a>
        </div>
    @endforeach
    
</div>


...
// import classes needed to create your own instance
use Modules\Adsense\Entities\Space;
use Modules\Adsense\Entities\Ad;

class HomepageController {
    ...
    /**
     * controller method
     */
    public function displayHomepage()
    {
        // make a new Space instance
        $mySpace = new Space;
        $mySpace ->system_name = 'custom_space';
        
        // create ad 1
        $ad1 = new Ad;
        $ad1->title = 'First Ad';
        $ad1->caption = 'First ad text';
        $ad1->external_image_url = 'https://placeholdit.imgix.net/~text?txtsize=33&txt=Ad1&w=800&h=300';
        
        // create ad 2
        $ad2 = new Ad;
        $ad2->title = 'Second Ad';
        $ad2->caption = 'Second ad text';
        $ad2->external_image_url = 'https://placeholdit.imgix.net/~text?txtsize=33&txt=Ad2&w=800&h=300';
        
        // add ads to space
        $mySpace->ads->add($ad1);
        $mySpace->ads->add($ad2);
        
        // render view
        return View::make('homepage')
            ->with('mySpace', $mySpace);
    }