-
Can I use Wiki.Page to somehow display a random section from a given page?
Hello- Using Mindtouch Core on a local test server. We have a fun page in our Wiki called "Need a laugh?" Each video or picture on this page is separated into it's own section using headers. I would like to somehow randomly pull a section of this page into a section on our main page, either with every page load or once a day. Does anyone know how I could make this happen automatically?
I'm new to mindtouch deki, but very impressed thus far. I just wish I had found it before we implemented our MediaWiki installation. 
Thanks for the help!
Curt
-
hi Curt!! welcome to this community 
I've prepared a code in our SandBox pages with two samples, one to get all sections of a page and other to get a random section, yo can see its:
- Source code of samples: http://gurework.com/MindTouch/SandBo...&action=source
- Samples in action: http://gurework.com/MindTouch/SandBox/Page_Sections
- The page that samples are using to get sections: http://gurework.com/OpenKoop
If you want to maintain the same random page for a day, you could use WebCache cache functions, i've prepare another simple sample here:
- Source code: http://gurework.com/MindTouch/SandBo...&action=source
- Sample in action: http://gurework.com/MindTouch/SandBox/WebCache
You can combine this cache sample with the previous random sample to get a different random page section every day 
happy sharing
hugs!!
Mikel - @himikel
-
Awesome! Thanks Mikel!
You'll have to excuse my ignorance, but I'm having a hard time understanding how/where to use the code.
Here is what the source looks like on the SOURCE page:
<h5>Gangnam Style</h5>
<p>{{ media{ source: "http://www.youtube.com/watch?v=9bZkp7q19f0" } }}</p>
<h5>Gang Fight</h5>
<p>{{ media{ source: "http://www.youtube.com/watch?v=1GaKaGwch0U&list=UU67f2Qf7FYhtoUIF4Sf2 9cA&index=28&feature=plpp_video" } }}</p>
<h5>Russian Unicorn</h5>
<p>{{ media{ source: "http://www.youtube.com/watch?v=YjaZNYSt7o0&feature=relmfu" } }}</p>
<h5>TV Bloopers</h5>
<p>{{ media{ source: "http://www.youtube.com/watch?v=gVg2dQBi-wU" } }}</p>
<h5>Batman Payton</h5>
<p><img alt="payton_batman.jpg" class="internal default" src="/@api/deki/files/23/=payton_batman.jpg" /></p>
As you can see, the sections are established using h5 headers. Is there a more efficient way to divide the sections so that it will work with your code?
Also, for get random section, I see you have:
Path: '/OpenKoop'
Section #4 Len: 234
That looks like you might be identifying the specific section and its length that you want to pull. Not just any random section from the given page "/OpenKoop". Is that correct? Where have I gone wrong?
Thanks again for your assistance!!
Curt
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules