Create a new static page using blogdown with same hugo theme as main site - r

I'm using the R package blogdown to create a hugo-powered website. Specifically i'm using the gcushen/hugo-academic theme.
The tutorials by #xieyihui and #apreshill have been wonderfully helpful to get started, and adding new posts is clear, but what about a new static page that uses the same theme as the overall site?
I get that it can be as simple as creating a new .md file with
+++
date = "2017-08-01"
title = "new_page_test"
type = "pages"
+++
## new page test
stuff
My questions are
where do I store this file so that it is copied properly to the public folder?
how to I link to this new page from another page? I'm not clear on the organization of the final file structure that gets published.

I'm doing this for my classes. You can see the end result here, click on "teaching". You can see the source files in the GitHub repository. In particular look under the content/classes folder.
Create a folder under content. I called it classes but it can be called anything. Add an _index.md file to this folder. I edited _index.md from the posts folder so it would automatically create a list of the contents of /classes.
This is drop dead easy! The relative link to a page, say content/yourstuff/yourpage.html is, wait for it, yourstuff/yourpage.html. With an index file in yourstuff the relative link is just yourstuff/. Follow the same structure to add subdirectories. I was blown away.

Related

In Wordpress website, connecting to another web_based application

I want to create a page in word press website, that shows information from external DB by API. What should I do?
But other pages and theme are in the Wordpress database.
Thanks in Advance
Set up a custom template. It can contain all the custom code you need, such as the API to call the external database. You create a new template by copying and modifying the page.php file from your theme. Just remove the parts you don't want and at the top put your new template name in a comment line like this:
/* Template Name: External-DB-Page */
Save that to a file such as external_db.php, upload it to your theme or child theme directory and then in your functions.php you include the file by adding
require_once 'external_db.php';
This new template called "External-DB-Page" will now be a selection available when choosing a page template for any page in WordPress.

How to add a file to wordpress theme from apparence->editor?

How to create a new file in my wordpress theme without using ftp client ?
thanks !
Using touch(); PHP function, which creates a new file in the specified directory. This is how I suggest doing it (and admittedly, there are cleaner ways, but this will get the job done, quickly and effectively)…
Open header.php — then write this code in the very top of the file:
<?php touch('wp-content/themes/YOUR_THEME_DIR/FILE_NAME.php');?>
Replace YOUR_THEME_DIR with the directory in which your WordPress theme lives.
Then, replace FILE_NAME with the name of the file you want to create.
Once that’s all done, save Header.php and go to the homepage of your site.
As soon as the homepage loads, it will create that new template or theme file.
Source :
https://www.webmechanix.com/how-to-create-a-new-theme-file-in-wordpress-without-ftp-access/
You can use a plugin called WPIDE found here https://wordpress.org/plugins/wpide/
This plugin will allow you to edit and add folder and files in your project.

Front End of Wordpress Plugin

This is my first plugin that i am developing. I have only one file in my plugin folder which has all the code that is handling my admin part. I have my own custom tables. I'm not using any wordpress table for it.
Structure:
plugin/amt
amt.php (This file has all the code which is dealing with admin part)
js/amt.js
Now I have got amt.php file working for my admin part. It is retrieving and saving data into the database. Till here its all fine.
Now, I want to add some functionality in the plugin which will be shown on frontend of the website. Please guide me, how can this be done? I could think of following options:
Add front end code in amt.php as well and use some kind of short code to display on front end of website under 'Sample Page'.
Need to create a new folder/file for front end?
I'll be thankful if some one can guide me please.
I have got it working with the help of short code. Here is what i did. added this code in my main plugin file i.e: amt.php
add_shortcode( 'clan', 'clan_fn' );
function clan_fn() { }
Create a new page from word press admin and simply call the short code as below and it will display what ever functionality you add in clan_fn.
[clan]

How can i edit the default drupal node view page

I am trying to edit the default page view of a node in Drupal and i found the file called node.tpl.php but even if i change it, the node page on the site isn't updated...
So how can i update the node view page so i can added some text, images etc.. ?
I guess that node_show function () { } is the one that displays the node but the code there doesn't give me enough detail on where the HTML is created so i can it
You need to copy the file to your theme's templates folder and clear the cache out before you can use this file. The original file should be at root/modules/node/
You can also set a template up for a specific content type by copying the default node.tpl.php file and renaming it to node--CONTENT_TYPE_MACHINE_NAME.tpl.php

separate js file for front page

I am working on a drupal 7 site and am very new to this. I need to create a totally separate home page from the rest of the site. I notice the head is built in the html.tpl.php file where all the scripts are loaded. I would rather not load scripts to the rest of the site that will only be used on the front page. Also I have found that drupal adds some code to the end of my script rendering it useless.
/js/image_scale.js?lwhgie"
What is going on here and how do get better control of this?
Thanks
Just to add a couple of points:
If you want to aggregate your homepage JS (which you may or may not) then you shouldn't add the stylesheets manually to the template file. You can add them in hook_preprocess_page(), something like this:
/**
* Implements hook_preprocess_page().
*/
function MYMODULE_preprocess_page(&$vars) {
if ($vars['is_front']) {
$path = drupal_get_path('module', 'MYMODULE');
drupal_add_js($path . '/MYMODULE1.js');
drupal_add_js($path . '/MYMODULE2.js');
$vars['scripts'] = drupal_get_js();
}
}
Also I have found that drupal adds some code to the end of my script rendering it useless.
/js/image_scale.js?lwhgie"
That shouldn't render your script useless. From the comments in drupal_get_js():
A dummy query-string is added to filenames, to gain control over
browser-caching. The string changes on every update or full cache
flush, forcing browsers to load a new copy of the files, as the
URL changed. Files that should not be cached (see drupal_add_js())
get time() as query-string instead, to enforce reload on every
page request.
you could create a new template called page--front.tpl.php in your theme folder and this will be your template for the homepage. Now you can add/remove any html markup you want. for more info take a look here: http://drupal.org/node/1089656 . Also, you could "tell" drupal to use your custom template file using hook_preprocess_page() in template.php file in your theme folder. See the comments on the link I posted earlier

Resources