Add new entries to the "Social Links" Dashboard page

Permalink
I have just tried to add a a new link using the instructions from the tutorial but it does not work with the current version of C5.

Call to a member function getServiceIconHTML() on null

The code I used.

return array(
'social' => array(
'additional_services' => array(
array(
'trip_advisor',
'Trip Advisor',
'tripadvisor',
),
),
),
)


I have used this method previously with 5.7.
I assume that the tutorial needs to be updated.

Colin

cmerritt
 
cmerritt replied on at Permalink Reply
cmerritt
Bump
linuxoid replied on at Permalink Reply
linuxoid
Have a look in: concrete\src\Sharing\SocialNetwork\ServiceList.php

I simply use an HTML block to add whatever extra links I need with Font Awesome icons
mesuva replied on at Permalink Best Answer Reply
mesuva
A bug was introduced with the extending/overriding of the social links at some point.

Instead of merging the list, it ended up overwriting the entries (and that's what triggers the error).

A fix has been merged via github though, so should be available in the next release.

In the meantime, you could manually update the file in your core:
concrete/src/Sharing/SocialNetwork/ServiceList.php
to the contents here:
https://github.com/Mesuva/concrete5/blob/e2a0fe1b0bde58c3e37d1ae8cdb...

With that change in place, the method in the doco works as intended.
HFUK replied on at Permalink Reply
I had the same problem but have now solved it.
Messing about with the Social Links can add null links to the database which cause display errors, rendering the page useless. I've added a test to catch these spurious entries and delete them, fixing the problem and restoring normal page functionality.

In the file:
concrete / single_pages / dashboard / system / basics / social.php

Starting at line 98, I modified:
<?php foreach ($links as $link) {
   $service = $link->getServiceObject();
   ?>
   <tr>
      <td style="width: 48px"><?=$service->getServiceIconHTML()?></td>
      <td><a href="<?=$view->action('edit', $link->getID())?>"><?= $service->getDisplayName() ?></a></td>
      <td><?= h($link->getURL()) ?></td>
   </tr>
   <?php 
   }
   ?>

To:
<?php foreach ($links as $link) {
   $service = $link->getServiceObject();
   if ($service != null) {
   ?>
   <tr>
      <td style="width: 48px"><?= $service->getServiceIconHTML() ?></td>
      <td><a href="<?= $view->action('edit', $link->getID()) ?>"><?= $service->getDisplayName() ?></a></td>
      <td><?= h($link->getURL()) ?></td>
   </tr>
   <?php 
   }
   else $link->delete();
   }
   ?>

Clear the cache then try the Social Links page again. Should now work as expected.
Added bonus: the fix can be left in place without any consequences, so you can continue fiddling. Result!