danpros / htmly

Simple and fast databaseless PHP blogging platform, and Flat-File CMS
https://www.htmly.com
GNU General Public License v2.0
1.07k stars 263 forks source link

How to add custom social buttons? (Independent Publisher theme) #752

Closed ashraf21c closed 4 months ago

ashraf21c commented 4 months ago

Hello, I`m trying to locate the code of social icons included in "independent publisher" theme. I want to add more (custom) ones.

I found these codes: [layout.html.php] <div id="menu-social" class="menu"> <?php echo social();?> </div>

[style.css] lines 2430:2610.. an example is below: #menu-social li a[href*="codepen.io"]::before { content: '\f216'; color: #BBC7D3;

I wasn`t able to find the code that includes the links already set for the social icons. Can you help me? Thanks in advance.

danpros commented 4 months ago

Hello,

The CSS code for the built-in social icon is social-logos.css.

The function: https://github.com/danpros/htmly/blob/5c45a61faa3ff848c45529b50f679d33742e7c2d/system/includes/functions.php#L2392

To include the new link using social() function than we need to modify the core (not recommended).

Try to create custom config in dashboard, example social.codepen than print it in layout.html.php:

<?php echo config('social.codepen');?>
ashraf21c commented 4 months ago

Thank you very much for the reply.. I`ll have a look.

ashraf21c commented 4 months ago

Hello, I tried doing as instructed, but the website halted (HTMLy is not installed)

I did this edit in layout.html.php, and did the requcired change inside the dashboard. (added the code "<?php echo config('social.email');?>" (No quotes) and the value "mailto:em414903@gmail.com".

This (automatically) caused this change in config.ini

; Framework config. No need to edit. views.layout = "layout" <?php echo config('social.email');?> = "mailto:em414903@gmail.com"

As a result, the website halted. (HTMLy is not installed) The problem persists, even after undoing the change and restoring the original file.

I added the last line (below), in config.ini

; Social account social.twitter = "" social.facebook = "https://www.facebook.com/eesoo.e?mibextid=hIlR13" social.instagram = "" social.linkedin = "" social.github = "" social.youtube = "" social.mastodon = "" social.tiktok = "" social.email = "mailto:em414903@gmail.com"

The error log says: [21-May-2024 13:23:20 America/Chicago] PHP Warning: syntax error, unexpected '(' in config/config.ini on line 191 in /home2/prizesciedu/public_html/sch/sites/israa-mohammed/system/includes/dispatch.php on line 104 [21-May-2024 13:23:26 America/Chicago] PHP Warning: syntax error, unexpected '(' in config/config.ini on line 191 in /home2/prizesciedu/public_html/sch/sites/israa-mohammed/system/includes/dispatch.php on line 104 [21-May-2024 13:25:19 America/Chicago] PHP Warning: syntax error, unexpected '(' in config/config.ini on line 191 in /home2/prizesciedu/public_html/sch/sites/israa-mohammed/system/includes/dispatch.php on line 104 [21-May-2024 13:25:22 America/Chicago] PHP Warning: syntax error, unexpected '(' in config/config.ini on line 191 in /home2/prizesciedu/public_html/sch/sites/israa-mohammed/system/includes/dispatch.php on line 104 [21-May-2024 13:25:31 America/Chicago] PHP Warning: syntax error, unexpected '(' in config/config.ini on line 191 in /home2/prizesciedu/public_html/sch/sites/israa-mohammed/system/includes/dispatch.php on line 104

I had a look Lines 99-109:

function config($key, $value = null) { static $_config = array();

if ($key === 'source' && file_exists($value))
    $_config = parse_ini_file($value, true);
elseif ($value == null)
    return (isset($_config[$key]) ? $_config[$key] : null);
else
    $_config[$key] = $value;

}

The line #104 is $_config = parse_ini_file($value, true);

Note 1: I tried both "mailto:......." version and "just the email address" version. The problem persists (HTMLy is not installed). Note2: If it matters, this time the theme is Papermod.

danpros commented 4 months ago

Hello,

Please check this line:

PHP Warning: syntax error, unexpected '(' in config/config.ini on line 191
ashraf21c commented 4 months ago

Yes, this is what the log says, but there is none!

(1) PHP Warning: syntax error, unexpected '(' in config/config.ini on line 191 There is no ' in line #191 of config.ini. image

(2) PHP Warning: syntax error, unexpected '(' in config/config.ini on line 191 in /system/includes/dispatch.php on line 104 There is no ' in line #104 of dispatch.php. image

(I use Notepad++)

danpros commented 4 months ago

No you should just put:

social.config = "username@example.com"

The <?php echo config(social.email);?> it should paste in template file and not in config file or even in custom config page.

So when adding custom config, you just need to fill social.email for the key and username@example.com for the value. Please read the hint on the page.