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

Show some kind of dynamic content

Started by Muut Archive 11 years ago · 15 replies · 1292 views
11 years ago

I evaluate at the moment grav, whether I can use it for my specific case or not.

My requirement is the following:
I have generated documentation html files with doxygen. These files contain HTML.
Now when a user calls: www.MyDomain.com/doc/api-1-0-0/classes.html
I need to load the file called "classes.html" and embed it's content into my base website template.

Is this possible with grav, when yes, how?

11 years ago

try to see the "page-inject plugin", which includes a grav page within another page, I think you can easly modify it to include your html page.

11 years ago

The thing is, I have to load the file content of the html page depending on the provided URL.
E.g.: www.MyDomain.com/doc/api-1-0-0/classes.html I have to load 'doc/api-1-0-0/classes.html'
On this page I have other links, which then have to load on request.

Can I do this with grav?

11 years ago

You can do anything :) But it might be a little work.

2 options off the top of my head:

1) Ensure your Grav page structure mimics the HTML structure, and going to any .html page will automatically just work for a Grav page.

2) If you have a custom Grav page structure, you would probably need to write a custom plugin with some regex to search replace the URLs into your custom Grav structure.

11 years ago

I don't know what you mean with page structure of grav.

I think 1) cannot work, because I want to embed the content of the HTML file into my website. e.g. <div class="container"> %HTML content% </div>
I think it can be only done via a plugin, but I have to be able to retrieve the URL and depending on the URL I load a file and it render it into the page.

11 years ago

Well i would suggest having those files locally somewhere, rather than remotely.. it would be quite slow to get a remote file for every page. Like I said, a plugin might be needed but all it would have to do is load the .html file and inject that in the page. Easy enough in Grav.

Regarding page structure, read the docs on folders for more info.

11 years ago

What do you mean with remote? The files will be of course located on the same server somewhere in the page structure of grav (maybe under 03.doc/version-1-2-3/).
We are speaking of maybe 200 HTML files. These will be placed under one folder, e.g. "version-1-2-3"

Here is an example: http://image.diku.dk/shark/doxygen_pages/html/classes.html

11 years ago

Then speed shouldn't be a huge issue. I think i've provided enough information to get you started. It should be 100% possible. Short of actually doing all the work for you and testing it, the rest is on your shoulders :) Good luck!

11 years ago

Reading this thread, it appears that Grav won't do this "as is" and is going to take a certain level of customization to get it done. Plug-ins are not real hard, if you have some PHP development experience - at least a little. Do you?

11 years ago

My first approach was, using the file-content plugin, and forwarding the URL to the plugin.
However, Grav try's to load immediately the file, which is of course not an md file...
Here is my folder structure:

TXT
/user
   -/pages
      -/doc
         default.md
         myHTML.html

How to load the myHTML.html file and embed its raw content in the rendered grav page of 'default.md'?
So I get my main navigation menu and below the file content of myHTML.html.

The user URL to enter this page would be: www.mySite.com/doc/myHTML.html

11 years ago

Which file does Grav load immediately? For a user going to www.mySite.com/doc, Grav will use the file www.mySite.com/doc/default.md to open and render the template named default.html.twig.

11 years ago

when I load this URL: www.mySite.com/doc/myHTML.html grav will load the error.html.twig

Which is of course not what I want.

11 years ago

If you point your browser to www.mySite.com/doc, Grav will use the Markdown file it finds there (default.md) as the page and render it with the template default.html.twig.

So the code to include myHTML.html needs to be in the template. Don't navigate directly to the HTML file.

11 years ago

but this is the requirement, the URL has to be www.mySite.com/doc/myHTML.html
Within the loaded html, there are of course more links, which then has to be loaded too.

11 years ago

I don't know how to do that. I suppose custom code could be written to change the way Grav routes pages. At least the way I understand that Grav routes pages.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1319 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4045 9 years ago
Archive · by Muut Archive, 9 years ago
1 2920 9 years ago
Archive · by Muut Archive, 9 years ago
3 1104 9 years ago