procnewie
Members-
Posts
16 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
procnewie's Achievements
Jr. Member (3/6)
1
Reputation
-
I figured out only this: {$config->urls->admin}page/add/?parent_id=$page->id
-
I'd like to add an Add button after the Edit button on every page. I can make out a url that is working starting from the one i have in the admin panel. But isn't there some api call or something else to get an url to add a children to a page?
-
When you have lot of subpages it's unhandy to browse them
procnewie replied to procnewie's topic in Getting Started
Pretty happy in the end. I copy pasted the 2 mains function used in the basic-page and edited according with what i wanted to get. <?php include('./_head.php'); // include header markup ?> <div id='content'><?php // output 'headline' if available, otherwise 'title' echo "<h1>" . $page->get('headline|title') . "</h1>"; // output bodycopy echo $page->body; // render navigation to child pages //renderNav($page->children); $results = $page->children("limit=10"); $items = $results; if($items->count()) { echo "<ul class='nav' role='navigation'>"; // cycle through all the items foreach($items as $item) { // render markup for each navigation item as an <li> if($item->id == wire('page')->id) { // if current item is the same as the page being viewed, add a "current" class to it echo "<li class='current' aria-current='true'>"; } else { // otherwise just a regular list item echo "<li>"; } // markup for the link echo "<a href='$item->url$config->pageNumUrlPrefix$input->pageNum'>$item->title</a> "; // if the item has summary text, include that too if($item->summary) echo "<div class='summary'>$item->summary</div>"; // close the list item echo "</li>"; } echo "</ul>"; } $pagination = $results->renderPager(); echo $pagination; // TIP: Notice that this <div id='content'> section is // identical between home.php and basic-page.php. You may // want to move this to a separate file, like _content.php // and then include('./_content.php'); here instead, on both // the home.php and basic-page.php template files. Then when // you make yet more templates that need the same thing, you // can simply include() it from them. ?></div><!-- end content --> <aside id='sidebar'><?php if($page->numParents > 1) { // rootParent is the parent page closest to the homepage // you can think of this as the "section" that the user is in // so we'll assign it to a $section variable for clarity $section = $page->rootParent; // if there's more than 1 page in this section... if($section->hasChildren > 1) { // output sidebar navigation // see _init.php for the renderNavTree function //renderNavTree($section); $results = $page->rootParent->children("limit=10"); $items = $results; // if we've been given just one item, convert it to an array of items if($items instanceof Page) $items = array($items); // if there aren't any items to output, exit now if(count($items)) { // $out is where we store the markup we are creating in this function // start our <ul> markup echo "<ul class='nav nav-tree' role='navigation'>"; // cycle through all the items foreach($items as $item) { // markup for the list item... // if current item is the same as the page being viewed, add a "current" class and // visually hidden text for screen readers to it if($item->id == wire('page')->id) { echo "<li class='current' aria-current='true'><span class='visually-hidden'>Current page: </span>"; } else { echo "<li>"; } // markup for the link echo "<a href='$item->url$config->pageNumUrlPrefix$input->pageNum'>$item->title</a>"; // if the item has children and we're allowed to output tree navigation (maxDepth) // then call this same function again for the item's children if($item->hasChildren() && $maxDepth) { renderNavTree($item->children, $maxDepth-1); } // close the list item echo "</li>"; } // end our <ul> markup echo "</ul>"; } } $pagination = $results->renderPager(); echo $pagination; } // output sidebar text if the page has it echo $page->sidebar; ?></aside><!-- end sidebar --> <?php include('./_foot.php'); // include footer markup ?> -
When you have lot of subpages it's unhandy to browse them
procnewie replied to procnewie's topic in Getting Started
I followed my idea and at last is working. But if you know a better way to do this please show me. $results = $page->rootParent->children("limit=10"); $pagination = $results->renderPager(); echo "<ul>"; foreach($results as $result) { echo "<li><a href='{$result->url}$config->pageNumUrlPrefix$input->pageNum'>{$result->title}</a></li>"; } echo "</ul>"; echo $pagination; -
When you have lot of subpages it's unhandy to browse them
procnewie replied to procnewie's topic in Getting Started
A simple workaround would be to list the links appending the current /page$n to them. Not sure how to do that with the simple function. But probably i can do that with the more complex one. -
When you have lot of subpages it's unhandy to browse them
procnewie replied to procnewie's topic in Getting Started
Ok here what is my issue now. I have the sidebar but when i enter a page, and for example let's say that page is from "page2", the sidebar is showed starting from "page1". How i make the sidebar aware of where the page is, and show the right list? -
When you have lot of subpages it's unhandy to browse them
procnewie replied to procnewie's topic in Getting Started
Ok i have a good resault. I used only: $results = $page->children("limit=10"); echo $results->render(); And added the example css to my main.css. Now i'm trying to figure out how to have a sidebar that make any sense. -
When you have lot of subpages it's unhandy to browse them
procnewie replied to procnewie's topic in Getting Started
I'm sorry if i double post but i don't see how to edit the previous one. Apparently the code was incomplete, with that i got something that is near what i wanted: echo "<ul>"; foreach($results as $result) { echo "<li><a href='{$result->url}'>{$result->title}</a></li>"; } echo "</ul>"; echo $pagination; Except that i don't like the url of pages. "Page2, Page3" it's really ugly, i will try to customize it. -
When you have lot of subpages it's unhandy to browse them
procnewie replied to procnewie's topic in Getting Started
This is really what i'm looking for! But something is wrong. I tired this code but i get few numbers without titles and they go to nowhere: $results = $page->children("limit=10"); $pagination = $results->renderPager(); echo $pagination; It's really the default site. I only added subpages to the main tree. That's what i already got. But you will not get multiple pages only by that. -
I'm basically trying to use ProcessWire as a really simple and clean blog. At beginning with the basic profile i already liked the output. But now that i start to have lot of pages under the same category, i find it hard to explore. In my Pages, i actually made only few subpages that are my "categories" and inside them i made new pages as my "posts". Using the default page template. But they are listed together, and when they get to be too much, is feels wrong to show them all together. Something like 10 posts per page listed + some bar to get older posts and older posts 10 by 10 would be more interesting. It's just unpleasent to see a really long list and it also make really weird to use the sidebar to switch to another post. It just make me think to remove the sidebar, but that would really slow to read other posts. I know there is a Blog module, but it's really more than what i need! I like to have just my categories, and when you get on them a list of Titles + the short description (maybe if i figure out would be cool to have the first n words of the post instead of the description so i don't have to write one) I just want to customize the base template to not list all children, but to show only the first n and numbered bar to continue to older ones... Since it look like a common behaviour maybe i can be pointed to some example or whatever. By myself i can only figure out how to show only the firt n children, but i can't think about how to get multiple pages. Thank you
-
Thank you! Is working just perfectly! ?
-
I'm sorry that i can not edit my previous posts. The firefox issue is documented in mathjax. I need to set something in my web server to solve it. I really don't like to use a cdn, but including a local versionl seems more than just the simple javascript file. About the AdminOnSteroids, i'm not sure i would load such a thing only to get mathjax.
-
And if i local the library, it doesn't work at all. Even if i see in the development console that the file is loaded fine.
-
On Chrome it's fast. On Firefox console i get a lot of errors related to a missing header CORS “Access-Control-Allow-Origin” . I guess that will slow down a bit things since there a lot of related to http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/fonts/HTML-CSS/TeX/otf/MathJax*.otf Even if i'm not really sure where those links come from... They are not in my sources anywhere...
-
Nevermind. Thank you anyway since you pointed me in the right direction. Opening the console and loading the page showed me an error saying that mathjax was missing the configuration. So i went again to configuration file and i discovered that if some-config.js exist, options in config.js are ignored... So i moved the conf from config.js to config-body.js and now is working. Is really really slow thought.