# How I set up my campaign logs
> [!summary]
> I use Templater and Dataview to create a framework for my log organization and pulls out last session's summary and links to the previous and the next for easy way to chain link my logs. You can see the [[#Outcome]] at the bottom.
I was asked about how I set up my campaign log in Obsidian so here it is as comprehensible as possible. This is the current edition (2023-05-11) as I am prone to make updates whenever fancy strikes me. I have added Explanation callouts after every section for my madness for having them in my note.
## Required Plugins
- [blacksmithgu](https://github.com/blacksmithgu)/**[obsidian-dataview](https://github.com/blacksmithgu/obsidian-dataview)**- This is a must have for any Obsidian user as it helps you to create automated lists tables and even calendar based on the parameter you set.
- [SilentVoid13](https://github.com/SilentVoid13)/**[Templater](https://github.com/SilentVoid13/Templater)** - This is basic Template Core Plug in on steroids. It allows you to set up so much more complex tasks, and more if you know how to code unlike myself.
> [!warning]
> I do not auto run these scripts when the notes are created since I need to have some of the metadata to populated before running the script, else it would spit out null links everywhere.
# The Log Template
> [!Quote] Metadata Section (comments in brackets and since I cannot post --- before breaking my post)
> type: log
>
> date: <% tp.date.now("YYYY-MM-DD") %>
>
> title: (In case I want to have a fancier title than the plain campaign log)
>
> aliases: (I've had this from previous set up and under consideration to remove it completely but for now it's there in case I want an alternative name to this particular log.)
>
> campaign:
>
> session:
>
> actors: (who are the player characters)
>
> tags:
>
> - ttrpg
>
<<[[ <% tp.frontmatter.campaign %> - Campaign Log - <% tp.frontmatter.session-1 %> ]] | [[ <% tp.frontmatter.campaign %> - Campaign Log - <% tp.frontmatter.session+1 %> ]]>>
> [!tip] Explanation
> This creates links for the previous and the next session log by pulling the metadata information the format would turn out as **Campaign name** - Campaign Log - **Session #**. This also helps me to create the next session file with the session number as a reminder and able to copy and paste the campaign name and session number into the metadata. (I've had cases I had two sessions with the same number by accident)
# `=this.campaign` - `=this.session`
# Last Session
![[ <% tp.frontmatter.campaign %> - Campaign Log - <% tp.frontmatter.session-1 %>#What Actually Happened ]]
> [!tip] Explanation
> This fetches the last session's summary as a preview and it would render once script is run. Do remember if there's an apostrophe in your campaign name, make sure the metadata has quotations around it. "Long's Heist" and not Long's Heist. The latter would not parse and tell you the the file does not exist.
# Session Summary
| Date | Actors |
| ------------ | -------------- |
| `=this.date` | `=this.actors` |
> [!example]- Other Sessions
> ```dataview
> table without ID link(file.link, file.frontmatter.title) as Title, session as Session, date as Date
> from #ttrpg
>where file.name != this.file.name and contains(campaign,this.campaign)and contains(type,this.type)
> sort file.day desc
> limit 12
>```
>For every sessions so far, go to [[TTRPG Sessions Index]]
> [!Tip] Explanation
> This is the Dataview segment that creates a table looking under the ttrpg tag that matches the note type (log) and contains the same campaign name as this log's. I did make a decision to sort them by day the file was created and you can set it to sort by session. I've set to 12 as the limit as some of my campaigns are longer than 50 sessions and that list is long (also why this is in a collapsible callout.). Note it also contains a clause to not include the file itself so if this is your first log, then it would be blank.
>
> Also the last bit is to linking all my logs directly to the index file.
<% await tp.file.move("/40 TTRPG/41 Session logs/" + tp.frontmatter.campaign + " - Campaign Log - " + tp.frontmatter.session) %>
> [!tip] Explanation
> This is just to move my log into a specific folder and rename it appropriately based on campaign and session number.
# What is Suppose to Happen
> [!Tip] Explanation
> This is when I am being a GM and prepare for the sessions and what I expect things to happen. Usually I prepare things outside of this log and pull them in as a links and previews. Such information include;
> - Character
> - Location
> - Event
> - Item
>
> I create notes with metadata type as such types to sort them out in their own way so it is easier for me to visualize them by using Dataview.
# What Actually Happened
> [!tip] Explanation
> Things don't go as planned as GM and this is what actually happens instead of what was expected. Meanwhile as a play this is pretty much what I write in here and usually I create links for Character, Location Event and Item.
---
# Outcome
So after all that it looks something like this:
![[Sample Campaign Log.png]]