Jump to content

clsource

Members
  • Posts

    374
  • Joined

  • Last visited

  • Days Won

    8

Community Answers

  1. clsource's post in Menu Building was marked as the answer   
    My menus work like this
    First create a "menu" template,
    a simple empty template that will hold "menu-item" pages as children.
    Then create the "menu-item" template that can hold 'menu-item' pages as children,
    fill it with these fields :
    - (title field) The title for the menu
    - (item field) A page reference (Single Page or NullPage) field that will link any page in the site except pages with menu or menu-item template.
    - (isExternalLink field) A checkbox that tells if the link is outside the site.
    - (externalLink field) a Textbox that holds the external url if the checkbox isExternalLink is active.
    You can add many additional fields depending on your needs, like css, js, or other information.
    When that is done just create a page named "Menu" with the "menu" template,
    later add children pages with the "menu-item" template.
    Now you have a menu that can be rendered
    like any other page in processwire.
    $menu = $pages->get('/menu'); foreach($menu->children as $menu_item) { if($menu_item->isExternalLink){ echo "{$menu_item->externalLink}"; } else { echo "{$menu_item->item->url}"; } } With this approach you can rely on the Processwire backend
    to give order to the items and create as many children and deep levels as you like
  2. clsource's post in Hook to suppress setting of session cookie was marked as the answer   
    Normally using $this is for modules only.
    Inside templates you should use wire() methods
    you can also get the object via the $event var.
    wire()->addHookBefore('Session::logout', null, 'logoutNoCookie'); function logoutNoCookie(HookEvent $event) { $hookObject = $event->object; } See also
    http://processwire.com/apigen/class-HookEvent.html
    https://processwire.com/talk/topic/4701-add-hook-in-a-template/
    https://processwire.com/api/hooks/#all_or_one
    http://www.flamingruby.com/blog/using-hooks-to-alter-default-behavior-of-processwire/
    Cheers
  3. clsource's post in are there better fields naming convention? was marked as the answer   
    I think I found a temporary solution.
    I wish there was someway to sort field selection in templates using categories.
    The solution is the following
    create a models directory in /templates/
    prefix fields as normal
    For example an user
    usrFirstName
    a model named /models/User.php

    that wraps all the user related data
    <?php class User { public $firstname; public $page; public function __construct($user) { // fill the vars $this->firstname = $user->usrFirstName; $this->page = $user; } // finds a specific user and creates a new User Object public static function get($id) { $userPage = wire('pages')->get("/users/$id"); $user = NullPage; if(!($userPage instanceOf NullPage)) $user = new User($userPage); return $user; } } Now you can have pretty property names like
    $user = User::get('clsource'); echo $user->firstname;
  4. clsource's post in Pw Supports Http Verbs (Get, Post, Put, Delete)? was marked as the answer   
    i Think this could answer https://processwire.com/talk/topic/6849-getting-page-field-data-outside-pw/
    my own question xdd
    thanks
  5. clsource's post in Bulk saving pages was marked as the answer   
    Yes, works like a charm.
    But also I discovered 2 issues.
    1.- the csv have not \n line endings.
    2.- the sql export have all the sessions. that was the main reason it was a very huge sql file (near 12 megas)
    after the truncate only was 140 kb. wow.
    Thanks folks!
  6. clsource's post in Export Profile was marked as the answer   
    So, I managed to make a complete migration.
    but something went wrong
    The development server was in root /
    and the production server was in a sub directory /pw
    All the links were mess up.
    So how I fixed it?

    Change all redirections inside my templates
    from using path to url
    $people = $pages->get('/system/people'); // Changed this $session->redirect($people->path); $session->redirect($people->url); made a backup of the site dumping the complete database.  Copied and and pasted the files, changing the mysql connection in config.php.

    Still the links were Wrong.

    So I installed the site in Localhost, and using Export Module I managed to make a install profile.
    and success!, complete migration from develop server to production.
×
×
  • Create New...