Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Twig in Quark to Insert Ad Script to All Pages

Started by David Colburn 2 years ago · 8 replies · 291 views
2 years ago

I've read the docs re. twigs as well as looking at the default Quark theme's file system.

(I looked for where 'frontmatter' is auto-generated for each page (parent or child) but had trouble finding a doc for that.)

Are these instructions from 2017 still best practice for inserting an ad script into the theme - so that it repeats on every parent and child page? /forum/archive/adsense-script-in-grav-content-t4792

NOTE1: I'm using yllix ads, not google.

NOTE2: The script is "text/javascript".

Thanks.

2 years ago

Doesn't look like a good solution. I'd rather extend the theme and insert the script to base template(s)

2 years ago

@Karmalakas:
extend the theme

Thanks!

I found this thread ...
/forum/themes-styling/included-grav-logo-svg-missing-on-extending-theme-t7522

Then visited here ...
https://github.com/getgrav/grav-theme-quark/blob/develop/quark.php

Where rhuk wrote: "... use Devtools plugin to create a new ‘inherited’ theme. It does most of the work for you."

I read ...
https://github.com/getgrav/grav-plugin-devtools/blob/master/README.md

So, do I create a new theme (a copy of Quark with a different name), then paste my yllix ad script in at line 20 of ~/quark.php (the "public function" section)?

2 years ago

@nginxgrav, Please read the docs to get to know the basic concepts of Grav. Looking at your questions, the lack of insight hinders you from progressing. It also leads to more load on the community.

The community is very much willing to help, but we appreciate it when a user shows self provisioning by:

  • Doing research:
    1. Firstly, by doing research on the topic in the docs, which provides a central place for all concepts.
    2. Searching Github (Grav, theme. plugin) to find out if issue is already a known issue.
    3. Searching this forum for similar issue.
  • Show what has been tried and where one got stuck.
    • Show well formatted (using triple backticks) code snippets (no screenshots) if helpful
    • What is expected to happen.
    • What does happen instead.

To give a few hints about adding js/css scripts/libraries:

last edited 01/26/24 by pamtbaau
2 years ago

I'm really trying to do the best I can to learn and apply. I'm not a developer/programmer, I'm an end user. (I tried to show that I had done 1, 2, & 3. I'm also 68 and don't learn quite as quickly as I used to.)

Thanks for the additional links.

OK re. "inheriting" vs "copying" - they sound very similar to me so I'll have to parse that some before the difference is clear enough to me.

2 years ago

@nginxgrav:
I’m not a developer/programmer, I’m an end user.

Grav has been developed with developers in mind. Admin has been added later as an add-on, to facilitate editing pages and simple config changes by less skilled users. If a user requires more changes than provided by Admin and theme, a basic set of skill and conceptual knowledge will be required.

Tools like Wix (and other drag&drop website builders) or Wordpress.com are much more accessible to end-users who wish to build websites.

last edited 01/26/24 by pamtbaau
2 years ago

I plan to go far beyond a Web site but chose to start relatively simply.
I have started just pasting the ad script into each page but saw a learning opportunity in discovering how to automate that process in the theme.
8,700 people in our university town will now become aware of grav. Some will be developers in the GSU computer and engineering program.

2 years ago

I never even noticed the "Cookbook" area. That's awesome! Thanks!

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 74 6 hours ago
General · by pamtbaau, 12 hours ago
1 47 11 hours ago
General · by Andy Miller, 24 hours ago
0 44 24 hours ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 39 5 days ago