I have an extension that dynamically creates content for some pages.
E.g. I have creates headlines with the <html> <h1>, <h2> and <h3>.
I want my mediawiki to react to the headline tags to create a directory dynamically.
I already tried using == in the specific tags in my extension, but mediawiki simply creates the string which will be displayed.
How can I achieve my goal?
Thanks in advance.
Are you hooking to ParserFirstCallInit?
You may need to parse the wikitext that you're returning, before returning it. Use something like $out = $parser->recursiveTagParse( "== Wikitext here ==" );
Alternatively, if you just want to return raw HTML, you can return an array of the form [ 0 => $outputHtml, 'isHTML' => true ].
I'm not sure what you mean by "create a directory dynamically" but if you're just trying to create HTML in a wikipage then the above should work.
Related
I want to generate some static html files from a template and a large set of datas.
This "set" is an uploaded json (ie a blob that became a file) that I want to read in the generated page using javascript, so I was thinking about inserting it as a string into a <script> tag of the page (something like <script>json=MYJSON</script>, I don't know if it's the best way to achieve this ...).
Now the question is how to copy a file (template) and add/edit a part of it (a tag) in the new file...
It seems that the simplest way is to use copy and give GET parameters to the template wich get it with a php code that echoes the tag .. for example here with a 'name' GET parameter :
copy('http://localhost/site/template.php/?name=' . $name, '../public/new_file.html');
It works fine, but the problem is that I can't pass a large data using this method, so how to achieve this ?
So my school has this very annoying way to view my rooster.
you have to bypass 5 links to get to my rooster.
this is the link for my class (it updates weekly without changing the link)
https://webuntis.a12.nl/WebUntis/?school=roc%20a12#Timetable?type=1&departmentId=0&id=2147
i want to display the content from that page on my website but with my
own stylesheet.
i don't mean this:
<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>
or an iframe....
I think this can be better done using jquery and ajax. You can get jquery to load the target page, use selectors to strip out what you need, then attach it to your document tree. You should then be able to style it anyway you like.
I would recommend you to use the cURL library: http://www.php.net/manual/en/curl.examples.php
But you have to extract part of the page you want to display, because you will get the whole HTML document.
You'd probably read the whole page into a string variable (using file_get_contents like you mentioned for example) and parse the content, here you have some possibilities:
Regular expressions
Walking the DOM tree (eg. using PHPs DOMDocument classes)
After that, you'd most likely replace all the style="..." or class="..." information with your own.
I have the following complex xml source (example at : http://www.fluffyduck.com.au/sampleXML.xml) if it is viewed within a browser, the parent/child method of being displayed = perfect
this is exactly what I am after. However I need to display it within a webpage recursively using php and be able to retrieve each attribute in a table / tree format that is expandable.
I'm tried jstree to no success, jquery.treetable no success, converting to xslt no success.
I am sure it is my lack of experience with these tools, however there must be a way to manipulate the data and display it in a working expandable tree method like chrome does when viewing the above link.
thanks for your help everyone
-- edit to include some sample code :
after multiple tests and no luck, i've gone back to basics using examples from jstree page, utilising xml sample from above link, I had to remove all code above the first tag.
then rename all tags to to conform to jstree requirements, doing this seems to display the correct tree, but no data.
so I then just inserted after the first 3 records test1 etc test2 / test3 but only the first name along side the arrow is displayed.
$(function () {
$("#demo2").jstree({
"xml_data" : {
"ajax" : {
"url" : "../moo.xml"
},
"xsl" : "nest"
},
"plugins" : [ "themes", "xml_data" ]
});
});
The problem here resulted in the source that was supplying the XML to me.
I could not modify it.
but when i manually edited the file so the header was
and the main node was
followed by each records node being
it started to work, i now just need to work out how to do that automatically.
I am new to php and I want to create an php engine which changes the web content of a webpage with PHP with the use of data in mysql. For example (changing the order of navigation links on a webpage with the order of highest click count) I am not sure how PHP will read the HTML file and change the elements in the HTML file and also output the HTML file with the changes. Is this possible?
I am not quite sure why you would want to generate the html, read it, change it and then output it. It seems to be a lot easier to just generate it the way you want to in the first place.
I am not sure how PHP will read the HTML file and change the elements in the HTML file and also output the HTML file with the changes. Is this possible?
You could use file_get_contents:
$html = file_get_contents($url);
Then use a html-parser like Simple HTML DOM Parser, change what you want to do and output it.
If you want to modify HTML structure, use ganon - HTML DOM parser for PHP
include('path/ganon.php');
// Parse the google code website into a DOM
$html = file_get_dom('http://code.google.com/');
foreach($html('p[class]') as $element) {
echo $element->class, "<br>\n";
}
I'm currently writing a TYPO3 extension which is configured with a list of tt_content UID's.
These point to content elements of type "text" and i want to render them by my extension.
Because of TYPO3s special way of transforming the text you enter in the rich text editing when it enters the database, and again transforming it when it is rendered to the frontend, i can not just output the database contents of the bodytext field.
I want to render these texts as they would usually get rendered by TYPO3.
How do I do that?
PHP
That works for me; it renders any content element with the given ID:
function getCE($id)
{
$conf['tables'] = 'tt_content';
$conf['source'] = $id;
$conf['dontCheckPid'] = 1;
return $GLOBALS['TSFE']->cObj->cObjGetSingle('RECORDS', $conf);
}
See http://lists.typo3.org/pipermail/typo3-dev/2007-May/023467.html
This does work for non-cached plugins, too. You will get a string like <!--INT_SCRIPT.0f1c1787dc3f62e40f944b93a2ad6a81-->, but TYPO3 will replace that on the next INT rendering pass with the real content.
Fluid
If you're in a fluid template, the VHS content.render view helper is useful:
<v:content.render contentUids="{0: textelementid}"/>
If your fluidcontent element has a grid itself, you can render the elements with flux' own content.get or content.render view helper:
<f:section name="Configuration>
... <flux:grid.column name="teaser"/> ...
</f:section>
<f:section name="Main>
<flux:content.render area="teaser"/>
<f:section>
I had the same problem a couple of months ago. Now I must say that I am no typo3 developer, so I don't know if this is the right solution.
But I used something like this:
$output .= $this->pi_RTEcssText( $contentFromDb );
in my extension and it works.